Apache Log4cxx  Version 2.0.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 using DateFormat::format;
118 void format( LogString& toAppendTo, log4cxx_time_t tm ) const override;
119
120 private:
128 static void millisecondFormat(int millis,
129 LogString& buf,
130 int offset);
131
132
133 public:
141 void setTimeZone(const helpers::TimeZonePtr& zone) override;
142
148 void numberFormat( LogString& toAppendTo, int n ) const override;
149
158
159 private:
161 CachedDateFormat& operator=(const CachedDateFormat&);
162
172 static bool regionMatches(
173 const LogString& target,
174 size_t toffset,
175 const LogString& other,
176 size_t ooffset,
177 size_t len);
178
179};
180
181
182
183} // namespace helpers
184} // namespace log4cxx
185
186#endif // _LOG4CXX_HELPERS_SIMPLE_DATE_FORMAT_H
DateFormat is an abstract class for date/time formatting patterned after java.text....
Definition dateformat.h:34
void numberFormat(LogString &toAppendTo, int n) 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.
void format(LogString &toAppendTo, log4cxx_time_t tm) const override
Formats a Date into a date/time string.
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.
Definition cacheddateformat.h:26
std::basic_string< logchar > LogString
Definition logstring.h:51