You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ts...@apache.org on 2019/08/23 17:29:32 UTC
[logging-log4cxx] 01/02: CachedDateFormat: Remove magic numbers
from header
This is an automated email from the ASF dual-hosted git repository.
tschoening pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 24125060f6d2e1b68187bec8eb1ff064a85520db
Author: Klemens Schölhorn <kl...@advantest.com>
AuthorDate: Wed Aug 21 15:03:18 2019 +0200
CachedDateFormat: Remove magic numbers from header
Instead define them as consts like all the other private constants.
Ideally, those should not be part of the header at all.
---
src/main/cpp/cacheddateformat.cpp | 19 ++++++++++++--
.../include/log4cxx/helpers/cacheddateformat.h | 29 ++++++++++++----------
2 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/src/main/cpp/cacheddateformat.cpp b/src/main/cpp/cacheddateformat.cpp
index b6084ee..45b374a 100644
--- a/src/main/cpp/cacheddateformat.cpp
+++ b/src/main/cpp/cacheddateformat.cpp
@@ -39,14 +39,29 @@ using namespace log4cxx::pattern;
*/
const logchar CachedDateFormat::digits[] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0 };
+
+/**
+ * First magic number (in microseconds) used to detect
+ * the millisecond position.
+ */
+const int CachedDateFormat::magic1 = 654000;
+
+
/**
- * Expected representation of first magic number.
+ * Expected representation of first magic number in milliseconds.
*/
const logchar CachedDateFormat::magicString1[] = { 0x36, 0x35, 0x34, 0 };
/**
- * Expected representation of second magic number.
+ * Second magic number (in microseconds) used to detect
+ * the millisecond position.
+ */
+const int CachedDateFormat::magic2 = 987000;
+
+
+/**
+ * Expected representation of second magic number in milliseconds.
*/
const logchar CachedDateFormat::magicString2[] = { 0x39, 0x38, 0x37, 0};
diff --git a/src/main/include/log4cxx/helpers/cacheddateformat.h b/src/main/include/log4cxx/helpers/cacheddateformat.h
index 5e94fda..2f4cb7b 100644
--- a/src/main/include/log4cxx/helpers/cacheddateformat.h
+++ b/src/main/include/log4cxx/helpers/cacheddateformat.h
@@ -50,26 +50,29 @@ class LOG4CXX_EXPORT CachedDateFormat : public log4cxx::helpers::DateFormat
*/
static const logchar digits[];
- enum
- {
- /**
- * First magic number used to detect the millisecond position.
- */
- magic1 = 654000,
- /**
- * Second magic number used to detect the millisecond position.
- */
- magic2 = 987000
- };
/**
- * Expected representation of first magic number.
+ * First magic number (in microseconds) used to detect
+ * the millisecond position.
+ */
+ static const int magic1;
+
+
+ /**
+ * Expected representation of first magic number in milliseconds.
*/
static const logchar magicString1[];
/**
- * Expected representation of second magic number.
+ * Second magic number (in microseconds) used to detect
+ * the millisecond position.
+ */
+ static const int magic2;
+
+
+ /**
+ * Expected representation of second magic number in milliseconds.
*/
static const logchar magicString2[];