Apache log4cxx  Version 0.12.1
optionconverter.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_HELPER_OPTION_CONVERTER_H
19 #define _LOG4CXX_HELPER_OPTION_CONVERTER_H
20 
21 #include <log4cxx/logstring.h>
22 #include <log4cxx/helpers/object.h>
23 
24 namespace log4cxx
25 {
26 class Level;
27 class File;
28 typedef std::shared_ptr<Level> LevelPtr;
29 
30 namespace spi
31 {
32 class LoggerRepository;
33 typedef std::shared_ptr<LoggerRepository> LoggerRepositoryPtr;
34 }
35 
36 namespace helpers
37 {
38 class Properties;
39 
40 class Object;
41 typedef std::shared_ptr<Object> ObjectPtr;
42 
43 class Class;
44 
46 class LOG4CXX_EXPORT OptionConverter
47 {
49  private:
50  OptionConverter() {}
51 
52  public:
53  static LogString convertSpecialChars(const LogString& s);
54 
63  static bool toBoolean(const LogString& value, bool dEfault);
64  static int toInt(const LogString& value, int dEfault);
65  static long toFileSize(const LogString& value, long dEfault);
66  static LevelPtr toLevel(const LogString& value,
67  const LevelPtr& defaultValue);
68 
74  static LogString findAndSubst(const LogString& key, Properties& props);
75 
110  static LogString substVars(const LogString& val, Properties& props);
111 
119  static LogString getSystemProperty(const LogString& key, const LogString& def);
120 
131  static ObjectPtr instantiateByClassName(const LogString& className,
132  const Class& superClass, const ObjectPtr& defaultValue);
133 
134  static ObjectPtr instantiateByKey(Properties& props,
135  const LogString& key, const Class& superClass,
136  const ObjectPtr& defaultValue);
137 
157  static void selectAndConfigure(const File& configFileName,
158  const LogString& clazz, spi::LoggerRepositoryPtr hierarchy);
159 };
160 } // namespace helpers
161 } // namespace log4cxx
162 
163 #endif //_LOG4CXX_HELPER_OPTION_CONVERTER_H
164 
std::shared_ptr< Level > LevelPtr
Definition: optionconverter.h:27
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition: defaultconfigurator.h:27
std::shared_ptr< Object > ObjectPtr
Definition: propertysetter.h:28
Definition: properties.h:38
Definition: class.h:37
A convenience class to convert property values to specific types.
Definition: optionconverter.h:46
An abstract representation of file and directory path names.
Definition: file.h:45
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66