LCOV - code coverage report
Current view: top level - unodevtools/source/unodevtools - options.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 30 0.0 %
Date: 2014-04-11 Functions: 0 2 0.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 <stdio.h>
      21             : 
      22             : #include "codemaker/global.hxx"
      23             : #include "rtl/ustring.hxx"
      24             : #include "rtl/process.h"
      25             : #include "unodevtools/options.hxx"
      26             : 
      27             : using namespace ::rtl;
      28             : 
      29             : namespace unodevtools {
      30             : 
      31             : 
      32             : #if OSL_DEBUG_LEVEL > 1
      33             : static void out( const sal_Char * pText )
      34             : {
      35             :     fprintf( stderr, pText );
      36             : }
      37             : #endif
      38             : 
      39             : 
      40           0 : bool readOption( OUString * pValue, const sal_Char * pOpt,
      41             :                      sal_uInt32 * pnIndex, const OUString & aArg)
      42             : {
      43           0 :     const OUString dash = "-";
      44           0 :     if(aArg.indexOf(dash) != 0)
      45           0 :         return false;
      46             : 
      47           0 :     OUString aOpt = OUString::createFromAscii( pOpt );
      48             : 
      49           0 :     if (aArg.getLength() < aOpt.getLength())
      50           0 :         return false;
      51             : 
      52           0 :     if (aOpt.equalsIgnoreAsciiCase( aArg.copy(1) )) {
      53             :         // take next argument
      54           0 :         ++(*pnIndex);
      55             : 
      56           0 :         rtl_getAppCommandArg(*pnIndex, &pValue->pData);
      57           0 :         if (*pnIndex >= rtl_getAppCommandArgCount() ||
      58           0 :             pValue->copy(1).equals(dash))
      59             :         {
      60             :             throw CannotDumpException(
      61           0 :                 "incomplete option \"-" + aOpt + "\" given!");
      62             :         } else {
      63             : #if OSL_DEBUG_LEVEL > 1
      64             :             out( "\n> identified option -" );
      65             :             out( pOpt );
      66             :             out( " = " );
      67             :             OString tmp = OUStringToOString(*pValue, RTL_TEXTENCODING_ASCII_US);
      68             :               out( tmp.getStr() );
      69             : #endif
      70           0 :             ++(*pnIndex);
      71           0 :             return true;
      72             :         }
      73           0 :     } else if (aArg.indexOf(aOpt) == 1) {
      74           0 :         *pValue = aArg.copy(1 + aOpt.getLength());
      75             : #if OSL_DEBUG_LEVEL > 1
      76             :         out( "\n> identified option -" );
      77             :         out( pOpt );
      78             :         out( " = " );
      79             :         OString tmp = OUStringToOString(*pValue, RTL_TEXTENCODING_ASCII_US);
      80             :         out( tmp.getStr() );
      81             : #endif
      82           0 :         ++(*pnIndex);
      83             : 
      84           0 :         return true;
      85             :     }
      86           0 :     return false;
      87             : }
      88             : 
      89             : 
      90           0 : bool readOption( sal_Bool * pbOpt, const sal_Char * pOpt,
      91             :                      sal_uInt32 * pnIndex, const OUString & aArg)
      92             : {
      93           0 :     const OUString dashdash("--");
      94           0 :     const OUString dash("-");
      95           0 :     OUString aOpt = OUString::createFromAscii(pOpt);
      96             : 
      97           0 :     if((aArg.startsWith(dash) && aOpt.equalsIgnoreAsciiCase(aArg.copy(1))) ||
      98           0 :        (aArg.startsWith(dashdash) && aOpt.equalsIgnoreAsciiCase(aArg.copy(2))) )
      99             :     {
     100           0 :         ++(*pnIndex);
     101           0 :         *pbOpt = sal_True;
     102             : #if OSL_DEBUG_LEVEL > 1
     103             :         out( "\n> identified option --" );
     104             :         out( pOpt );
     105             : #endif
     106           0 :         return true;
     107             :     }
     108           0 :     return false;
     109             : }
     110             : 
     111             : } // end of namespace unodevtools
     112             : 
     113             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10