Apache Log4cxx  Version 1.8.0
Loading...
Searching...
No Matches
cacheddateformat.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _LOG4CXX_HELPERS_CACHED_DATE_FORMAT_H
19#define _LOG4CXX_HELPERS_CACHED_DATE_FORMAT_H
20
22
23namespace LOG4CXX_NS
24{
25namespace pattern
26{
27class LOG4CXX_EXPORT CachedDateFormat : public helpers::DateFormat
28{
29 public:
30 enum
31 {
32 /*
33 * Constant used to represent that there was no change
34 * observed when changing the millisecond count.
35 */
37 /*
38 * Constant used to represent that there was an
39 * observed change, but was an expected change.
40 */
42 };
43
44 private:
51 static const logchar digits[];
52
53
58 static const int magic1;
59
60
64 static const logchar magicString1[];
65
66
71 static const int magic2;
72
73
77 static const logchar magicString2[];
78
79
83 static const logchar zeroString[];
84
85 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(CachedDateFormatPriv, m_priv)
86
87 public:
96 CachedDateFormat(const helpers::DateFormatPtr& dateFormat, int expiration);
98
109 log4cxx_time_t time, const LogString& formatted,
110 const helpers::DateFormatPtr& formatter);
111#if LOG4CXX_ABI_VERSION <= 15
112 [[deprecated("Use findMillisecondStart() without a Pool parameter instead")]]
114 log4cxx_time_t time, const LogString& formatted,
115 const LOG4CXX_NS::helpers::DateFormatPtr& formatter,
116 LOG4CXX_NS::helpers::Pool& pool);
117#endif
118 using DateFormat::format;
126
127 private:
135 static void millisecondFormat(int millis,
136 LogString& buf,
137 int offset);
138
139
140 public:
148 void setTimeZone(const helpers::TimeZonePtr& zone) override;
149
156
165
166 private:
168 CachedDateFormat& operator=(const CachedDateFormat&);
169
179 static bool regionMatches(
180 const LogString& target,
181 size_t toffset,
182 const LogString& other,
183 size_t ooffset,
184 size_t len);
185
186};
187
188
189
190} // namespace helpers
191} // namespace log4cxx
192
193#endif // _LOG4CXX_HELPERS_SIMPLE_DATE_FORMAT_H
DateFormat is an abstract class for date/time formatting patterned after java.text....
Definition dateformat.h:34
static int findMillisecondStart(log4cxx_time_t time, const LogString &formatted, const log4cxx::helpers::DateFormatPtr &formatter, log4cxx::helpers::Pool &pool)
void format(LogString &toAppendTo, log4cxx_time_t tm, helpers::Pool &p) const override
Formats a Date into a date/time string.
void numberFormat(LogString &toAppendTo, int n, helpers::Pool &p) const override
Format an integer consistent with the format method.
static int getMaximumCacheValidity(const LogString &pattern)
Gets maximum cache validity for the specified SimpleDateTime conversion pattern.
CachedDateFormat(const helpers::DateFormatPtr &dateFormat, int expiration)
Creates a new CachedDateFormat object.
void setTimeZone(const helpers::TimeZonePtr &zone) override
Set timezone.
@ NO_MILLISECONDS
Definition cacheddateformat.h:36
@ UNRECOGNIZED_MILLISECONDS
Definition cacheddateformat.h:41
static int findMillisecondStart(log4cxx_time_t time, const LogString &formatted, const helpers::DateFormatPtr &formatter)
Finds start of millisecond field in formatted time.
#define LOG4CXX_FORMAT_NUMBER_FORMAL_PARAMETERS
Definition dateformat.h:90
#define LOG4CXX_FORMAT_TIME_FORMAL_PARAMETERS
Formats an log4cxx_time_t into a date/time string.
Definition dateformat.h:52
Definition cacheddateformat.h:26
std::basic_string< logchar > LogString
Definition logstring.h:60