Apache log4cxx  Version 0.12.0
ndc.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_NDC_H
19 #define _LOG4CXX_NDC_H
20 
21 #include <log4cxx/log4cxx.h>
22 #include <log4cxx/logstring.h>
23 #include <stack>
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 
95 class LOG4CXX_EXPORT NDC
96 {
97  public:
101  typedef std::pair<LogString, LogString> DiagnosticContext;
102  typedef std::stack<DiagnosticContext> Stack;
103 
116  NDC(const std::string& message);
117 
123  ~NDC();
124 
130  static void clear();
131 
143  static Stack* cloneStack();
144 
157  static void inherit(Stack* stack);
158 
165  static bool get(LogString& dest);
166 
170  static int getDepth();
171 
172 
176  static bool empty();
177 
182  static LogString pop();
188  static bool pop(std::string& buf);
189 
197  static LogString peek();
203  static bool peek(std::string& buf);
204 
211  static void push(const std::string& message);
218  static void pushLS(const LogString& message);
219 
236  static void remove();
237 
238 #if LOG4CXX_WCHAR_T_API
239 
251  NDC(const std::wstring& message);
258  static void push(const std::wstring& message);
264  static bool peek(std::wstring& dst);
270  static bool pop(std::wstring& dst);
271 #endif
272 #if LOG4CXX_UNICHAR_API
273 
285  NDC(const std::basic_string<UniChar>& message);
292  static void push(const std::basic_string<UniChar>& message);
298  static bool peek(std::basic_string<UniChar>& dst);
304  static bool pop(std::basic_string<UniChar>& dst);
305 #endif
306 #if LOG4CXX_CFSTRING_API
307 
319  NDC(const CFStringRef& message);
326  static void push(const CFStringRef& message);
332  static bool peek(CFStringRef& dst);
338  static bool pop(CFStringRef& dst);
339 #endif
340 
341  private:
342  NDC(const NDC&);
343  NDC& operator=(const NDC&);
344  static LogString& getMessage(DiagnosticContext& ctx);
345  static LogString& getFullMessage(DiagnosticContext& ctx);
346 }; // class NDC;
347 } // namespace log4cxx
348 
349 #if defined(_MSC_VER)
350  #pragma warning (pop)
351 #endif
352 
353 
354 #endif // _LOG4CXX_NDC_H
std::pair< LogString, LogString > DiagnosticContext
Pair of Message and FullMessage.
Definition: ndc.h:101
the ndc class implements nested diagnostic contexts as defined by neil harrison in the article "patte...
Definition: ndc.h:95
const struct __CFString * CFStringRef
Definition: logstring.h:36
std::stack< DiagnosticContext > Stack
Definition: ndc.h:102
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66