[89] | 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_SIMPLE_DATE_FORMAT_H
|
---|
| 19 | #define _LOG4CXX_HELPERS_SIMPLE_DATE_FORMAT_H
|
---|
| 20 |
|
---|
| 21 | #if defined(_MSC_VER)
|
---|
| 22 | #pragma warning ( push )
|
---|
| 23 | #pragma warning ( disable: 4231 4251 4275 4786 )
|
---|
| 24 | #endif
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | #include <log4cxx/helpers/dateformat.h>
|
---|
| 29 | #include <vector>
|
---|
| 30 | #include <time.h>
|
---|
| 31 |
|
---|
| 32 | namespace std { class locale; }
|
---|
| 33 |
|
---|
| 34 | namespace log4cxx
|
---|
| 35 | {
|
---|
| 36 | namespace helpers
|
---|
| 37 | {
|
---|
| 38 | namespace SimpleDateFormatImpl {
|
---|
| 39 | class PatternToken;
|
---|
| 40 | }
|
---|
| 41 | LOG4CXX_LIST_DEF(PatternTokenList, log4cxx::helpers::SimpleDateFormatImpl::PatternToken*);
|
---|
| 42 |
|
---|
| 43 | /**
|
---|
| 44 | * Concrete class for formatting and parsing dates in a
|
---|
| 45 | * locale-sensitive manner.
|
---|
| 46 | */
|
---|
| 47 | class LOG4CXX_EXPORT SimpleDateFormat : public DateFormat
|
---|
| 48 | {
|
---|
| 49 | public:
|
---|
| 50 | /**
|
---|
| 51 | * Constructs a DateFormat using the given pattern and the default
|
---|
| 52 | * time zone.
|
---|
| 53 | *
|
---|
| 54 | * @param pattern the pattern describing the date and time format
|
---|
| 55 | */
|
---|
| 56 | SimpleDateFormat(const LogString& pattern);
|
---|
| 57 | SimpleDateFormat(const LogString& pattern, const std::locale* locale);
|
---|
| 58 | ~SimpleDateFormat();
|
---|
| 59 |
|
---|
| 60 | virtual void format(LogString& s,
|
---|
| 61 | log4cxx_time_t tm,
|
---|
| 62 | log4cxx::helpers::Pool& p) const;
|
---|
| 63 |
|
---|
| 64 | /**
|
---|
| 65 | * Set time zone.
|
---|
| 66 | * @param zone new time zone.
|
---|
| 67 | */
|
---|
| 68 | void setTimeZone(const TimeZonePtr& zone);
|
---|
| 69 |
|
---|
| 70 | private:
|
---|
| 71 | /**
|
---|
| 72 | * Time zone.
|
---|
| 73 | */
|
---|
| 74 | TimeZonePtr timeZone;
|
---|
| 75 |
|
---|
| 76 | /**
|
---|
| 77 | * List of tokens.
|
---|
| 78 | */
|
---|
| 79 |
|
---|
| 80 | PatternTokenList pattern;
|
---|
| 81 |
|
---|
| 82 | static void addToken(const logchar spec, const int repeat, const std::locale* locale, PatternTokenList& pattern);
|
---|
| 83 | static void parsePattern(const LogString& spec, const std::locale* locale, PatternTokenList& pattern);
|
---|
| 84 | };
|
---|
| 85 |
|
---|
| 86 |
|
---|
| 87 | } // namespace helpers
|
---|
| 88 | } // namespace log4cxx
|
---|
| 89 |
|
---|
| 90 | #if defined(_MSC_VER)
|
---|
| 91 | #pragma warning ( pop )
|
---|
| 92 | #endif
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 | #endif // _LOG4CXX_HELPERS_SIMPLE_DATE_FORMAT_H
|
---|