xref: /trunk/main/sw/inc/dbgoutsw.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef __DBGOUTSW_HXX
24 #define __DBGOUTSW_HXX
25 
26 #ifdef DEBUG
27 
28 #include <hash_map>
29 #include <tox.hxx>
30 class String;
31 
32 namespace rtl
33 {
34 class OUString;
35 }
36 class SwNode;
37 class SwTxtAttr;
38 class SwpHints;
39 class SfxPoolItem;
40 class SfxItemSet;
41 struct SwPosition;
42 class SwPaM;
43 class SwNodeNum;
44 class SwUndo;
45 class SwRect;
46 class SwFrmFmt;
47 class SwFrmFmts;
48 class SwNodes;
49 class SwRewriter;
50 class SwNumRuleTbl;
51 class SwNumRule;
52 class SwOutlineNodes;
53 class SwTxtFmtColl;
54 class SwNodeRange;
55 
56 #define DBG_OUT_HERE printf("%s(%d):", __FILE__, __LINE__)
57 #define DBG_OUT_HERE_FN printf("%s(%d) %s:", __FILE__, __LINE__, __FUNCTION__)
58 #define DBG_OUT_HERE_LN printf("%s(%d)\n", __FILE__, __LINE__)
59 #define DBG_OUT_HERE_FN_LN printf("%s(%d) %s\n", __FILE__, __LINE__, __FUNCTION__)
60 #define DBG_OUT(x) printf("%s\n", dbg_out(x))
61 #define DBG_OUT_LN(x) printf("%s(%d): %s\n", __FILE__, __LINE__, dbg_out(x))
62 #define DBG_OUT_FN_LN(x) printf("%s: %s\n", __FUNCTION__, dbg_out(x))
63 
64 extern bool bDbgOutStdErr;
65 extern bool bDbgOutPrintAttrSet;
66 
67 SW_DLLPUBLIC const char * dbg_out(const void * pVoid);
68 SW_DLLPUBLIC const char * dbg_out(const String & aStr);
69 SW_DLLPUBLIC const char * dbg_out(const ::rtl::OUString & aStr);
70 SW_DLLPUBLIC const char * dbg_out(const SwRect & rRect);
71 SW_DLLPUBLIC const char * dbg_out(const SwFrmFmt & rFrmFmt);
72 SW_DLLPUBLIC const char * dbg_out(const SwNode & rNode);
73 SW_DLLPUBLIC const char * dbg_out(const SwTxtAttr & rAttr);
74 SW_DLLPUBLIC const char * dbg_out(const SwpHints &rHints);
75 SW_DLLPUBLIC const char * dbg_out(const SfxPoolItem & rItem);
76 SW_DLLPUBLIC const char * dbg_out(const SfxPoolItem * pItem);
77 SW_DLLPUBLIC const char * dbg_out(const SfxItemSet & rSet);
78 SW_DLLPUBLIC const char * dbg_out(SwNodes & rNodes);
79 // const char * dbg_out(SwOutlineNodes & rNodes);
80 SW_DLLPUBLIC const char * dbg_out(const SwPosition & rPos);
81 SW_DLLPUBLIC const char * dbg_out(const SwPaM & rPam);
82 SW_DLLPUBLIC const char * dbg_out(const SwNodeNum & rNum);
83 SW_DLLPUBLIC const char * dbg_out(const SwUndo & rUndo);
84 SW_DLLPUBLIC const char * dbg_out(const SwRewriter & rRewriter);
85 SW_DLLPUBLIC const char * dbg_out(const SwNumRule & rRule);
86 SW_DLLPUBLIC const char * dbg_out(const SwTxtFmtColl & rFmt);
87 SW_DLLPUBLIC const char * dbg_out(const SwFrmFmts & rFrmFmts);
88 SW_DLLPUBLIC const char * dbg_out(const SwNumRuleTbl & rTbl);
89 SW_DLLPUBLIC const char * dbg_out(const SwNodeRange & rRange);
90 
91 template<typename tKey, typename tMember, typename fHashFunction>
lcl_dbg_out(const std::hash_map<tKey,tMember,fHashFunction> & rMap)92 String lcl_dbg_out(const std::hash_map<tKey, tMember, fHashFunction> & rMap)
93 {
94     String aResult("[", RTL_TEXTENCODING_ASCII_US);
95 
96     typename std::hash_map<tKey, tMember, fHashFunction>::const_iterator aIt;
97 
98     for (aIt = rMap.begin(); aIt != rMap.end(); aIt++)
99     {
100         if (aIt != rMap.begin())
101             aResult += String(", ", RTL_TEXTENCODING_ASCII_US);
102 
103         aResult += aIt->first;
104 
105         char sBuffer[256];
106         sprintf(sBuffer, "(%p)", aIt->second);
107         aResult += String(sBuffer, RTL_TEXTENCODING_ASCII_US);
108     }
109 
110     aResult += String("]", RTL_TEXTENCODING_ASCII_US);
111 
112     return aResult;
113 }
114 
115 template<typename tKey, typename tMember, typename fHashFunction>
dbg_out(const std::hash_map<tKey,tMember,fHashFunction> & rMap)116 const char * dbg_out(const std::hash_map<tKey, tMember, fHashFunction> & rMap)
117 {
118     return dbg_out(lcl_dbg_out(rMap));
119 }
120 SW_DLLPUBLIC const char * dbg_out(const SwFormToken & rToken);
121 SW_DLLPUBLIC const char * dbg_out(const SwFormTokens & rTokens);
122 #endif // DEBUG
123 #endif // __DBGOUTSW_HXX
124