| 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | /* |
| 3 | * This file is part of the LibreOffice project. |
| 4 | * |
| 5 | * This Source Code Form is subject to the terms of the Mozilla Public |
| 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 | * |
| 9 | * This file incorporates work covered by the following license notice: |
| 10 | * |
| 11 | * Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 | * contributor license agreements. See the NOTICE file distributed |
| 13 | * with this work for additional information regarding copyright |
| 14 | * ownership. The ASF licenses this file to you under the Apache |
| 15 | * License, Version 2.0 (the "License"); you may not use this file |
| 16 | * except in compliance with the License. You may obtain a copy of |
| 17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 | */ |
| 19 | #pragma once |
| 20 | |
| 21 | #ifdef DBG_UTIL |
| 22 | |
| 23 | #include <rtl/ustring.hxx> |
| 24 | #include <rtl/ustrbuf.hxx> |
| 25 | #include "tox.hxx" |
| 26 | #include <cstdio> |
| 27 | #include <string_view> |
| 28 | #include <unordered_map> |
| 29 | |
| 30 | class SwContentNode; |
| 31 | class SwNode; |
| 32 | class SwTextAttr; |
| 33 | class SwTextNode; |
| 34 | class SwpHints; |
| 35 | class SfxPoolItem; |
| 36 | class SfxItemSet; |
| 37 | struct SwPosition; |
| 38 | class SwPaM; |
| 39 | class SwNodeNum; |
| 40 | class SwUndo; |
| 41 | class SwRect; |
| 42 | class SwFrameFormat; |
| 43 | class SwNumRuleTable; |
| 44 | class SwNumRule; |
| 45 | class SwOutlineNodes; |
| 46 | class SwTextFormatColl; |
| 47 | class SwNodeRange; |
| 48 | |
| 49 | extern bool bDbgOutStdErr; |
| 50 | extern bool bDbgOutPrintAttrSet; |
| 51 | |
| 52 | const char* dbg_out(const void* pVoid); |
| 53 | const char* dbg_out(std::u16string_view aStr); |
| 54 | const char* dbg_out(const SwRect& rRect); |
| 55 | const char* dbg_out(const SwFrameFormat& rFrameFormat); |
| 56 | SW_DLLPUBLIC const char* dbg_out(const SwNode& rNode); |
| 57 | SW_DLLPUBLIC const char* dbg_out(const SwNode* pNode); |
| 58 | const char* dbg_out(const SwContentNode* pNode); |
| 59 | const char* dbg_out(const SwTextNode* pNode); |
| 60 | const char* dbg_out(const SwTextAttr& rAttr); |
| 61 | const char* dbg_out(const SwpHints& rHints); |
| 62 | const char* dbg_out(const SfxPoolItem& rItem); |
| 63 | const char* dbg_out(const SfxPoolItem* pItem); |
| 64 | const char* dbg_out(const SfxItemSet& rSet); |
| 65 | const char* dbg_out(const SwPosition& rPos); |
| 66 | const char* dbg_out(const SwPaM& rPam); |
| 67 | const char* dbg_out(const SwNodeNum& rNum); |
| 68 | const char* dbg_out(const SwUndo& rUndo); |
| 69 | const char* dbg_out(SwOutlineNodes const& rNodes); |
| 70 | const char* dbg_out(const SwNumRule& rRule); |
| 71 | const char* dbg_out(const SwTextFormatColl& rFormat); |
| 72 | const char* dbg_out(const SwNumRuleTable& rTable); |
| 73 | const char* dbg_out(const SwNodeRange& rRange); |
| 74 | const char* dbg_out(const sw::FrameFormats<sw::SpzFrameFormat*>& rFrameFormats); |
| 75 | |
| 76 | template <typename tKey, typename tMember, typename fHashFunction> |
| 77 | OUString lcl_dbg_out(const std::unordered_map<tKey, tMember, fHashFunction>& rMap) |
| 78 | { |
| 79 | OUStringBuffer aResult("["); |
| 80 | |
| 81 | typename std::unordered_map<tKey, tMember, fHashFunction>::const_iterator aIt; |
| 82 | |
| 83 | for (aIt = rMap.begin(); aIt != rMap.end(); ++aIt) |
| 84 | { |
| 85 | if (aIt != rMap.begin()) |
| 86 | aResult.append(", "); |
| 87 | |
| 88 | aResult += aIt->first; |
| 89 | |
| 90 | char sBuffer[256]; |
| 91 | sprintf(sBuffer, "(%p)", aIt->second); |
| 92 | aResult.appendAscii(sBuffer); |
| 93 | } |
| 94 | |
| 95 | aResult.append("]"); |
| 96 | |
| 97 | return aResult.makeStringAndClear(); |
| 98 | } |
| 99 | |
| 100 | template <typename tKey, typename tMember, typename fHashFunction> |
| 101 | const char* dbg_out(const std::unordered_map<tKey, tMember, fHashFunction>& rMap) |
| 102 | { |
| 103 | return dbg_out(lcl_dbg_out(rMap)); |
| 104 | } |
| 105 | const char* dbg_out(const SwFormToken& rToken); |
| 106 | const char* dbg_out(const SwFormTokens& rTokens); |
| 107 | #endif // DBG_UTIL |
| 108 | |
| 109 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |