LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 CComAutoCriticalSection CPluginDebugLock::s_criticalSectionDebugLock; | 59 CComAutoCriticalSection CPluginDebugLock::s_criticalSectionDebugLock; |
60 | 60 |
61 /** | 61 /** |
62 * The polymorphic part of a log entry. | 62 * The polymorphic part of a log entry. |
63 */ | 63 */ |
64 class LogText | 64 class LogText |
65 { | 65 { |
66 public: | 66 public: |
67 virtual std::string Text() const = 0; | 67 virtual std::string Text() const = 0; |
| 68 virtual ~LogText() {}; |
68 }; | 69 }; |
69 | 70 |
70 class LogTextFixed | 71 class LogTextFixed |
71 : public LogText | 72 : public LogText |
72 { | 73 { |
73 protected: | 74 protected: |
74 const std::string fixedText; | 75 const std::string fixedText; |
75 | 76 |
76 public: | 77 public: |
77 explicit LogTextFixed(const std::string& text) | 78 explicit LogTextFixed(const std::string& text) |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 463 |
463 void Trace::ErrorCode(DWORD errorCode, const std::string& description, Trace::Lo
cation location) | 464 void Trace::ErrorCode(DWORD errorCode, const std::string& description, Trace::Lo
cation location) |
464 { | 465 { |
465 LogQueue::Insert(LogEntry(new LogTextErrorCode(errorCode, description), locati
on)); | 466 LogQueue::Insert(LogEntry(new LogTextErrorCode(errorCode, description), locati
on)); |
466 } | 467 } |
467 | 468 |
468 void Trace::TextFixed(const std::string& description, Trace::Location location) | 469 void Trace::TextFixed(const std::string& description, Trace::Location location) |
469 { | 470 { |
470 LogQueue::Insert(LogEntry(new LogTextFixed(description), location)); | 471 LogQueue::Insert(LogEntry(new LogTextFixed(description), location)); |
471 } | 472 } |
| 473 |
| 474 namespace |
| 475 { |
| 476 /* |
| 477 * To convert a pointer to a hexadecimal number, we need an integral type that
has the same size as that of the pointer. |
| 478 */ |
| 479 #if defined(_WIN64) |
| 480 typedef uint64_t voidIntegral; |
| 481 static_assert(sizeof(void*)==sizeof(voidIntegral),"WIN64: sizeof(uint64_t) is
not the same as sizeof(void*)"); |
| 482 #elif defined(_WIN32) |
| 483 typedef uint32_t voidIntegral; |
| 484 static_assert(sizeof(void*)==sizeof(voidIntegral),"WIN32: sizeof(uint32_t) is
not the same as sizeof(void*)"); |
| 485 #else |
| 486 #error Must compile with either _WIN32 or _WIN64 |
| 487 #endif |
| 488 } |
| 489 |
| 490 std::wstring ToHexLiteral(void const* p) |
| 491 { |
| 492 std::wstringstream ss; |
| 493 ss << L"0x"; |
| 494 ss.width(sizeof(p) * 2); |
| 495 ss.fill(L'0'); |
| 496 ss << std::hex << reinterpret_cast<voidIntegral>(p); |
| 497 return ss.str(); |
| 498 } |
LEFT | RIGHT |