LibreOffice Module configmgr (master) 1
parsemanager.cxx
Go to the documentation of this file.
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
20#include <sal/config.h>
21
22#include <cassert>
23#include <set>
24
25#include <sal/log.hxx>
26#include <sal/types.h>
27#include <xmlreader/span.hxx>
29
30#include "parsemanager.hxx"
31#include "parser.hxx"
32
33namespace configmgr {
34
36 OUString const & url, rtl::Reference< Parser > const & parser)
37 : reader_(url), parser_(parser), itemNamespaceId_(-1)
38{
39 assert(parser.is());
40 int id;
43 RTL_CONSTASCII_STRINGPARAM("http://openoffice.org/2001/registry")));
44 assert(id == NAMESPACE_OOR);
47 RTL_CONSTASCII_STRINGPARAM("http://www.w3.org/2001/XMLSchema")));
48 assert(id == NAMESPACE_XS);
51 RTL_CONSTASCII_STRINGPARAM(
52 "http://www.w3.org/2001/XMLSchema-instance")));
53 assert(id == NAMESPACE_XSI);
54 (void)id;
55}
56
57bool ParseManager::parse(std::set< OUString > const * existingDependencies) {
58 sal_uInt32 startTime( osl_getGlobalTimer() );
59 for (;;) {
60 switch (itemData_.is()
61 ? xmlreader::XmlReader::Result::Begin
63 parser_->getTextMode(), &itemData_, &itemNamespaceId_))
64 {
65 case xmlreader::XmlReader::Result::Begin:
66 if (!parser_->startElement(
67 reader_, itemNamespaceId_, itemData_, existingDependencies))
68 {
69 SAL_INFO("configmgr", "parsing " << reader_.getUrl() << " took " << (osl_getGlobalTimer() - startTime) << " ms, fail");
70 return false;
71 }
72 break;
73 case xmlreader::XmlReader::Result::End:
74 parser_->endElement(reader_);
75 break;
76 case xmlreader::XmlReader::Result::Text:
77 parser_->characters(itemData_);
78 break;
79 case xmlreader::XmlReader::Result::Done:
80 SAL_INFO("configmgr", "parsing " << reader_.getUrl() << " took " << (osl_getGlobalTimer() - startTime) << " ms, success");
81 return true;
82 }
84 }
85}
86
88
89}
90
91/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool parse(std::set< OUString > const *existingDependencies)
ParseManager(OUString const &url, rtl::Reference< Parser > const &parser)
rtl::Reference< Parser > parser_
xmlreader::XmlReader reader_
virtual ~ParseManager() override
xmlreader::Span itemData_
int registerNamespaceIri(Span const &iri)
const OUString & getUrl() const
Result nextItem(Text reportText, Span *data, int *nsId)
#define SAL_INFO(area, stream)
parser
void clear() noexcept
bool is() const