LCOV - code coverage report
Current view: top level - oox/source/token - tokenmap.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 20 20 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 "oox/token/tokenmap.hxx"
      21             : 
      22             : #include <string.h>
      23             : #include <rtl/strbuf.hxx>
      24             : #include <rtl/string.hxx>
      25             : #include "oox/token/tokens.hxx"
      26             : 
      27             : namespace oox {
      28             : 
      29             : using ::com::sun::star::uno::Sequence;
      30             : 
      31             : namespace {
      32             : // include auto-generated Perfect_Hash
      33             : #if defined __clang__
      34             : #if __has_warning("-Wdeprecated-register")
      35             : #pragma GCC diagnostic push
      36             : #pragma GCC diagnostic ignored "-Wdeprecated-register"
      37             : #endif
      38             : #endif
      39             : #include "tokenhash.inc"
      40             : #if defined __clang__
      41             : #if __has_warning("-Wdeprecated-register")
      42             : #pragma GCC diagnostic pop
      43             : #endif
      44             : #endif
      45             : } // namespace
      46             : 
      47          28 : TokenMap::TokenMap() :
      48          28 :     maTokenNames( static_cast< size_t >( XML_TOKEN_COUNT ) )
      49             : {
      50             :     static const sal_Char* sppcTokenNames[] =
      51             :     {
      52             : // include auto-generated C array with token names as C strings
      53             : #include "tokennames.inc"
      54             :         ""
      55             :     };
      56             : 
      57          28 :     const sal_Char* const* ppcTokenName = sppcTokenNames;
      58      162932 :     for( TokenNameVector::iterator aIt = maTokenNames.begin(), aEnd = maTokenNames.end(); aIt != aEnd; ++aIt, ++ppcTokenName )
      59             :     {
      60      162904 :         OString aUtf8Token( *ppcTokenName );
      61      162904 :         *aIt = Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aUtf8Token.getStr() ), aUtf8Token.getLength() );
      62      162904 :     }
      63             : 
      64         756 :     for (unsigned char c = 'a'; c <= 'z'; c++)
      65             :     {
      66             :         const struct xmltoken* pToken = Perfect_Hash::in_word_set(
      67         728 :                 reinterpret_cast< const char* >( &c ), 1 );
      68         728 :         mnAlphaTokens[ c - 'a' ] = pToken ? pToken->nToken : XML_TOKEN_INVALID;
      69             :     }
      70          28 : }
      71             : 
      72          28 : TokenMap::~TokenMap()
      73             : {
      74          28 : }
      75             : 
      76       36783 : sal_Int32 TokenMap::getTokenFromUnicode( const OUString& rUnicodeName )
      77             : {
      78       36783 :     OString aUtf8Name = OUStringToOString( rUnicodeName, RTL_TEXTENCODING_UTF8 );
      79       36783 :     const struct xmltoken* pToken = Perfect_Hash::in_word_set( aUtf8Name.getStr(), aUtf8Name.getLength() );
      80       36783 :     return pToken ? pToken->nToken : XML_TOKEN_INVALID;
      81             : }
      82             : 
      83     6171884 : sal_Int32 TokenMap::getTokenPerfectHash( const char *pStr, sal_Int32 nLength )
      84             : {
      85     6171884 :     const struct xmltoken* pToken = Perfect_Hash::in_word_set( pStr, nLength );
      86     6171877 :     return pToken ? pToken->nToken : XML_TOKEN_INVALID;
      87             : }
      88             : 
      89             : } // namespace oox
      90             : 
      91             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11