LCOV - code coverage report
Current view: top level - connectivity/source/drivers/mozab/bootstrap - MNSINIParser.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 37 40 92.5 %
Date: 2015-06-13 12:38:46 Functions: 1 1 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 "MNSINIParser.hxx"
      21             : #include <rtl/byteseq.hxx>
      22             : #include <osl/diagnose.h>
      23             : 
      24           3 : IniParser::IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException )
      25             : {
      26           3 :     OUString iniUrl;
      27           3 :     if (osl_File_E_None != osl_getFileURLFromSystemPath(rIniName.pData, &iniUrl.pData))
      28           3 :         return;
      29             : 
      30             : 
      31             : #if OSL_DEBUG_LEVEL > 0
      32             :     OString sFile = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
      33             :     OSL_TRACE(__FILE__" -- parser() - %s\n", sFile.getStr());
      34             : #endif
      35           3 :     oslFileHandle handle=NULL;
      36           3 :     oslFileError fileError = osl_File_E_INVAL;
      37             :     try{
      38           3 :         if (!iniUrl.isEmpty())
      39           3 :             fileError = osl_openFile(iniUrl.pData, &handle, osl_File_OpenFlag_Read);
      40             :     }
      41           0 :     catch(const ::com::sun::star::io::IOException&)
      42             :     {
      43             : #if OSL_DEBUG_LEVEL > 0
      44             :         OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
      45             :         OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() );
      46             : #endif
      47             :     }
      48             : 
      49           3 :     if (osl_File_E_None == fileError)
      50             :     {
      51           2 :         rtl::ByteSequence seq;
      52           2 :         sal_uInt64 nSize = 0;
      53             : 
      54           2 :         osl_getFileSize(handle, &nSize);
      55           4 :         OUString sectionName(  "no name section" );
      56             :         while (true)
      57             :         {
      58             :             sal_uInt64 nPos;
      59          24 :             if (osl_File_E_None != osl_getFilePos(handle, &nPos) || nPos >= nSize)
      60           4 :                 break;
      61          22 :             if (osl_File_E_None != osl_readLine(handle, reinterpret_cast<sal_Sequence **>(&seq)))
      62           0 :                 break;
      63          22 :             OString line(reinterpret_cast<const char *>(seq.getConstArray()), seq.getLength() );
      64          22 :             sal_Int32 nIndex = line.indexOf('=');
      65          22 :             if (nIndex >= 1)
      66             :             {
      67          12 :                 ini_Section *aSection = &mAllSection[sectionName];
      68          12 :                 struct ini_NameValue nameValue;
      69          24 :                 nameValue.sName = OStringToOUString(
      70          12 :                     line.copy(0,nIndex).trim(), RTL_TEXTENCODING_ASCII_US );
      71          24 :                 nameValue.sValue = OStringToOUString(
      72          12 :                     line.copy(nIndex+1).trim(), RTL_TEXTENCODING_UTF8 );
      73             : 
      74          12 :                 aSection->lList.push_back(nameValue);
      75             : 
      76             :             }
      77             :             else
      78             :             {
      79          10 :                 sal_Int32 nIndexStart = line.indexOf('[');
      80          10 :                 sal_Int32 nIndexEnd = line.indexOf(']');
      81          10 :                 if ( nIndexEnd > nIndexStart && nIndexStart >=0)
      82             :                 {
      83          10 :                     sectionName =  OStringToOUString(
      84          10 :                         line.copy(nIndexStart + 1,nIndexEnd - nIndexStart -1).trim(), RTL_TEXTENCODING_ASCII_US );
      85           5 :                     if (sectionName.isEmpty())
      86           0 :                         sectionName = "no name section";
      87             : 
      88           5 :                     ini_Section *aSection = &mAllSection[sectionName];
      89           5 :                     aSection->sName = sectionName;
      90             :                 }
      91             :             }
      92          22 :         }
      93           4 :         osl_closeFile(handle);
      94           3 :     }
      95             : #if OSL_DEBUG_LEVEL > 0
      96             :     else
      97             :     {
      98             :         OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
      99             :         OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() );
     100             :     }
     101             : #endif
     102             : }
     103             : 
     104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11