Apache log4cxx  Version 0.12.0
mdc.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_MDC_H
19 #define _LOG4CXX_MDC_H
20 
21 #include <log4cxx/log4cxx.h>
22 #include <log4cxx/logstring.h>
23 #include <map>
24 
25 #if defined(_MSC_VER)
26  #pragma warning (push)
27  #pragma warning ( disable: 4231 4251 4275 4786 )
28 #endif
29 
30 namespace log4cxx
31 {
32 
41 class LOG4CXX_EXPORT MDC
42 {
43  public:
46  typedef std::map<LogString, LogString> Map;
47 
55  MDC(const std::string& key, const std::string& value);
56  ~MDC();
57 
68  static void put(const std::string& key, const std::string& value);
77  static void putLS(const LogString& key, const LogString& value);
78 
86  static std::string get(const std::string& key);
93  static bool get(const LogString& key, LogString& dest);
94 
101  static std::string remove(const std::string& key);
102 #if LOG4CXX_WCHAR_T_API
103 
110  MDC(const std::wstring& key, const std::wstring& value);
121  static void put(const std::wstring& key, const std::wstring& value);
129  static std::wstring get(const std::wstring& key);
136  static std::wstring remove(const std::wstring& key);
137 #endif
138 #if LOG4CXX_UNICHAR_API
139 
146  MDC(const std::basic_string<UniChar>& key, const std::basic_string<UniChar>& value);
157  static void put(const std::basic_string<UniChar>& key, const std::basic_string<UniChar>& value);
165  static std::basic_string<UniChar> get(const std::basic_string<UniChar>& key);
172  static std::basic_string<UniChar> remove(const std::basic_string<UniChar>& key);
173 #endif
174 #if LOG4CXX_CFSTRING_API
175 
182  MDC(const CFStringRef& key, const CFStringRef& value);
193  static void put(const CFStringRef& key, const CFStringRef& value);
201  static CFStringRef get(const CFStringRef& key);
208  static CFStringRef remove(const CFStringRef& key);
209 #endif
210 
217  static bool remove(const LogString& key, LogString& prevValue);
218 
222  static void clear();
223 
224  private:
225  MDC(const MDC&);
226  MDC& operator=(const MDC&);
227  LogString key;
228 }; // class MDC;
229 } // namespace log4cxx
230 
231 #if defined(_MSC_VER)
232  #pragma warning (pop)
233 #endif
234 
235 
236 #endif // _LOG4CXX_MDC_H
std::map< LogString, LogString > Map
String to string stl map.
Definition: mdc.h:46
The MDC class is similar to the NDC class except that it is based on a map instead of a stack...
Definition: mdc.h:41
const struct __CFString * CFStringRef
Definition: logstring.h:36
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66