Bump version to 4.1-6
[LibreOffice.git] / writerfilter / source / resourcemodel / XPathLogger.cxx
bloba62d1f9aa4b589429d8fe2b0b9c9979388b06aa7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <stdio.h>
21 #include <resourcemodel/XPathLogger.hxx>
23 #ifdef DEBUG_CONTEXT_HANDLER
25 namespace writerfilter
27 XPathLogger::XPathLogger()
28 : mp_tokenMap(new TokenMap_t)
32 XPathLogger::~XPathLogger()
36 string XPathLogger::getXPath() const
38 return m_currentPath;
41 void XPathLogger::updateCurrentPath()
43 m_currentPath = "";
45 for (vector<string>::const_iterator aIt = m_path.begin();
46 aIt != m_path.end();
47 ++aIt)
49 if (m_currentPath.size() > 0)
50 m_currentPath += "/";
52 m_currentPath += *aIt;
56 void XPathLogger::startElement(string _token)
58 TokenMap_t::const_iterator aIt = mp_tokenMap->find(_token);
60 if (aIt == mp_tokenMap->end())
61 (*mp_tokenMap)[_token] = 1;
62 else
63 (*mp_tokenMap)[_token]++;
65 static char sBuffer[256];
66 snprintf(sBuffer, sizeof(sBuffer), "[%d]", (*mp_tokenMap)[_token]);
67 m_path.push_back(_token + sBuffer);
69 m_tokenMapStack.push(mp_tokenMap);
70 mp_tokenMap.reset(new TokenMap_t);
72 updateCurrentPath();
75 void XPathLogger::endElement()
77 mp_tokenMap = m_tokenMapStack.top();
78 m_tokenMapStack.pop();
79 m_path.pop_back();
81 updateCurrentPath();
84 } // namespace writerfilter
86 #endif
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */