Apache Log4cxx  Version 1.2.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 LOG4CXX_NS::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 */
36 NO_MILLISECONDS = -2,
37 /*
38 * Constant used to represent that there was an
39 * observed change, but was an expected change.
40 */
41 UNRECOGNIZED_MILLISECONDS = -1
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 LOG4CXX_NS::helpers::DateFormatPtr& dateFormat, int expiration);
98
110 log4cxx_time_t time, const LogString& formatted,
111 const LOG4CXX_NS::helpers::DateFormatPtr& formatter,
112 LOG4CXX_NS::helpers::Pool& pool);
113
121 virtual void format(LogString& sbuf,
122 log4cxx_time_t date,
123 LOG4CXX_NS::helpers::Pool& p) const;
124
125 private:
133 static void millisecondFormat(int millis,
134 LogString& buf,
135 int offset);
136
137
138 public:
146 virtual void setTimeZone(const LOG4CXX_NS::helpers::TimeZonePtr& zone);
147
154 virtual void numberFormat(LogString& s,
155 int n,
156 LOG4CXX_NS::helpers::Pool& p) const;
157
165 static int getMaximumCacheValidity(const LogString& pattern);
166
167 private:
169 CachedDateFormat& operator=(const CachedDateFormat&);
170
180 static bool regionMatches(
181 const LogString& target,
182 size_t toffset,
183 const LogString& other,
184 size_t ooffset,
185 size_t len);
186
187};
188
189
190
191} // namespace helpers
192} // namespace log4cxx
193
194#endif // _LOG4CXX_HELPERS_SIMPLE_DATE_FORMAT_H
Definition: cacheddateformat.h:28
CachedDateFormat(const log4cxx::helpers::DateFormatPtr &dateFormat, int expiration)
Creates a new CachedDateFormat object.
static int findMillisecondStart(log4cxx_time_t time, const LogString &formatted, const log4cxx::helpers::DateFormatPtr &formatter, log4cxx::helpers::Pool &pool)
Finds start of millisecond field in formatted time.
virtual void numberFormat(LogString &s, int n, log4cxx::helpers::Pool &p) const
Format an integer consistent with the format method.
virtual void format(LogString &sbuf, log4cxx_time_t date, log4cxx::helpers::Pool &p) const
Formats a Date into a date/time string.
static int getMaximumCacheValidity(const LogString &pattern)
Gets maximum cache validity for the specified SimpleDateTime conversion pattern.
virtual void setTimeZone(const log4cxx::helpers::TimeZonePtr &zone)
Set timezone.
std::basic_string< logchar > LogString
Definition: logstring.h:60