LCOV - code coverage report
Current view: top level - configmgr/source - parsemanager.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 22 22 100.0 %
Date: 2015-06-13 12:38:46 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 <com/sun/star/container/NoSuchElementException.hpp>
      26             : #include <com/sun/star/uno/RuntimeException.hpp>
      27             : #include <sal/log.hxx>
      28             : #include <sal/types.h>
      29             : #include <xmlreader/span.hxx>
      30             : #include <xmlreader/xmlreader.hxx>
      31             : 
      32             : #include "parsemanager.hxx"
      33             : #include "parser.hxx"
      34             : 
      35             : namespace configmgr {
      36             : 
      37        5228 : ParseManager::ParseManager(
      38             :     OUString const & url, rtl::Reference< Parser > const & parser)
      39        5228 :    : reader_(url), parser_(parser), itemNamespaceId_(-1)
      40             : {
      41             :     assert(parser.is());
      42             :     int id;
      43             :     id = reader_.registerNamespaceIri(
      44             :         xmlreader::Span(
      45        5173 :             RTL_CONSTASCII_STRINGPARAM("http://openoffice.org/2001/registry")));
      46             :     assert(id == NAMESPACE_OOR);
      47             :     id = reader_.registerNamespaceIri(
      48             :         xmlreader::Span(
      49        5173 :             RTL_CONSTASCII_STRINGPARAM("http://www.w3.org/2001/XMLSchema")));
      50             :     assert(id == NAMESPACE_XS);
      51             :     id = reader_.registerNamespaceIri(
      52             :         xmlreader::Span(
      53             :             RTL_CONSTASCII_STRINGPARAM(
      54        5173 :                 "http://www.w3.org/2001/XMLSchema-instance")));
      55             :     assert(id == NAMESPACE_XSI);
      56             :     (void)id;
      57        5173 : }
      58             : 
      59        6423 : bool ParseManager::parse(std::set< OUString > const * existingDependencies) {
      60        6423 :     sal_uInt32 startTime( osl_getGlobalTimer() );
      61             :     for (;;) {
      62    59722090 :         switch (itemData_.is()
      63             :                 ? xmlreader::XmlReader::RESULT_BEGIN
      64             :                 : reader_.nextItem(
      65    29860420 :                     parser_->getTextMode(), &itemData_, &itemNamespaceId_))
      66             :         {
      67             :         case xmlreader::XmlReader::RESULT_BEGIN:
      68    25229956 :             if (!parser_->startElement(
      69    12614978 :                     reader_, itemNamespaceId_, itemData_, existingDependencies))
      70             :             {
      71             :                 SAL_INFO("configmgr", "parsing " << reader_.getUrl() << " took " << (osl_getGlobalTimer() - startTime) << " ms, fail");
      72        1250 :                 return false;
      73             :             }
      74    12613728 :             break;
      75             :         case xmlreader::XmlReader::RESULT_END:
      76    12613728 :             parser_->endElement(reader_);
      77    12613728 :             break;
      78             :         case xmlreader::XmlReader::RESULT_TEXT:
      79     4627791 :             parser_->characters(itemData_);
      80     4627791 :             break;
      81             :         case xmlreader::XmlReader::RESULT_DONE:
      82             :             SAL_INFO("configmgr", "parsing " << reader_.getUrl() << " took " << (osl_getGlobalTimer() - startTime) << " ms, success");
      83        5173 :             return true;
      84             :         }
      85    29855247 :         itemData_.clear();
      86    29855247 :     }
      87             : }
      88             : 
      89       10346 : ParseManager::~ParseManager() {}
      90             : 
      91             : }
      92             : 
      93             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11