1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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
41 void XPathLogger::updateCurrentPath()
45 for (vector
<string
>::const_iterator aIt
= m_path
.begin();
49 if (m_currentPath
.size() > 0)
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;
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
);
75 void XPathLogger::endElement()
77 mp_tokenMap
= m_tokenMapStack
.top();
78 m_tokenMapStack
.pop();
84 } // namespace writerfilter
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */