| 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ |
| 2 | /* librevenge |
| 3 | * Version: MPL 2.0 / LGPLv2.1+ |
| 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 | * Major Contributor(s): |
| 10 | * Copyright (C) 2002 William Lachance ([email protected]) |
| 11 | * Copyright (C) 2002-2004 Marc Maurer ([email protected]) |
| 12 | * |
| 13 | * For minor contributions see the git repository. |
| 14 | * |
| 15 | * Alternatively, the contents of this file may be used under the terms |
| 16 | * of the GNU Lesser General Public License Version 2.1 or later |
| 17 | * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are |
| 18 | * applicable instead of those above. |
| 19 | */ |
| 20 | |
| 21 | #include "RVNGRawGeneratorBase.h" |
| 22 | |
| 23 | #include <stdarg.h> |
| 24 | #include <stdio.h> |
| 25 | #include <map> |
| 26 | #include <string> |
| 27 | |
| 28 | namespace librevenge |
| 29 | { |
| 30 | |
| 31 | RVNGRawGeneratorBase::RVNGRawGeneratorBase(bool printCallgraphScore) |
| 32 | : m_indent(0) |
| 33 | , m_callbackMisses(0) |
| 34 | , m_atLeastOneCallback(false) |
| 35 | , m_printCallgraphScore(printCallgraphScore) |
| 36 | , m_callStack() |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | RVNGRawGeneratorBase::~RVNGRawGeneratorBase() |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | void RVNGRawGeneratorBase::iprintf(const char *format, ...) |
| 45 | { |
| 46 | m_atLeastOneCallback = true; |
| 47 | if (m_printCallgraphScore) return; |
| 48 | |
| 49 | va_list args; |
| 50 | va_start(args, format); |
| 51 | for (int i=0; i<m_indent; i++) |
| 52 | printf(" "); |
| 53 | vprintf(format, args); |
| 54 | va_end(args); |
| 55 | } |
| 56 | |
| 57 | void RVNGRawGeneratorBase::iuprintf(const char *format, ...) |
| 58 | { |
| 59 | m_atLeastOneCallback = true; |
| 60 | va_list args; |
| 61 | va_start(args, format); |
| 62 | for (int i=0; i<m_indent; i++) |
| 63 | printf(" "); |
| 64 | vprintf(format, args); |
| 65 | indentUp(); |
| 66 | va_end(args); |
| 67 | } |
| 68 | |
| 69 | void RVNGRawGeneratorBase::idprintf(const char *format, ...) |
| 70 | { |
| 71 | m_atLeastOneCallback = true; |
| 72 | va_list args; |
| 73 | va_start(args, format); |
| 74 | indentDown(); |
| 75 | for (int i=0; i<m_indent; i++) |
| 76 | printf(" "); |
| 77 | vprintf(format, args); |
| 78 | va_end(args); |
| 79 | } |
| 80 | |
| 81 | } // namespace librevenge |
| 82 | |
| 83 | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |