LCOV - code coverage report
Current view: top level - include/vcl - strhelper.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 9 0.0 %
Date: 2014-04-14 Functions: 0 3 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             : #ifndef INCLUDED_VCL_STRHELPER_HXX
      20             : #define INCLUDED_VCL_STRHELPER_HXX
      21             : 
      22             : #include <cstring>
      23             : #include <rtl/math.hxx>
      24             : #include <rtl/ustring.hxx>
      25             : #include <vcl/dllapi.h>
      26             : 
      27             : namespace psp
      28             : {
      29             :     VCL_DLLPUBLIC OUString GetCommandLineToken( int, const OUString& );
      30             :     VCL_DLLPUBLIC OString GetCommandLineToken(int, const OString&);
      31             :     // gets one token of a unix command line style string
      32             :     // doublequote, singlequote and singleleftquote protect their respective
      33             :     // contents
      34             : 
      35             :     VCL_DLLPUBLIC int GetCommandLineTokenCount(const OUString&);
      36             :     // returns number of tokens (zero if empty or whitespace only)
      37             : 
      38             :     VCL_DLLPUBLIC OUString WhitespaceToSpace( const OUString&, bool bProtect = true );
      39             :     VCL_DLLPUBLIC OString WhitespaceToSpace(const OString&, bool bProtect = true);
      40             :     // returns a string with multiple adjacent occurrences of whitespace
      41             :     // converted to a single space. if bProtect is sal_True (nonzero), then
      42             :     // doublequote, singlequote and singleleftquote protect their respective
      43             :     // contents
      44             : 
      45             : 
      46             :     // parses the first double in the string; decimal is '.' only
      47           0 :     VCL_DLLPUBLIC inline double StringToDouble( const OUString& rStr )
      48             :     {
      49           0 :         return rtl::math::stringToDouble(rStr, sal_Unicode('.'), sal_Unicode(0));
      50             :     }
      51             : 
      52           0 :     VCL_DLLPUBLIC inline double StringToDouble(const OString& rStr)
      53             :     {
      54           0 :         return rtl::math::stringToDouble(rStr, '.', static_cast<sal_Char>(0));
      55             :     }
      56             : 
      57             :     // fills a character buffer with the string representation of a double
      58             :     // the buffer has to be long enough (e.g. 128 bytes)
      59             :     // returns the string len
      60           0 :     VCL_DLLPUBLIC inline int getValueOfDouble( char* pBuffer, double f, int nPrecision = 0)
      61             :     {
      62           0 :         OString aStr( rtl::math::doubleToString( f, rtl_math_StringFormat_G, nPrecision, '.', true ) );
      63           0 :         int nLen = aStr.getLength();
      64           0 :         std::strncpy( pBuffer, aStr.getStr(), nLen+1 ); // copy string including terminating zero
      65           0 :         return nLen;
      66             :     }
      67             : 
      68             : } // namespace
      69             : 
      70             : #endif // INCLUDED_VCL_STRHELPER_HXX
      71             : 
      72             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10