LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/drivers/file - quotedstring.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 51 0.0 %
Date: 2012-12-27 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 "file/quotedstring.hxx"
      21             : #include <rtl/logfile.hxx>
      22             : 
      23             : namespace connectivity
      24             : {
      25             :     //==================================================================
      26             :     //= QuotedTokenizedString
      27             :     //==================================================================
      28             :     //------------------------------------------------------------------
      29           0 :     xub_StrLen QuotedTokenizedString::GetTokenCount( sal_Unicode cTok, sal_Unicode cStrDel ) const
      30             :     {
      31             :         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "QuotedTokenizedString::GetTokenCount" );
      32           0 :         const xub_StrLen nLen = m_sString.Len();
      33           0 :         if ( !nLen )
      34           0 :             return 0;
      35             : 
      36           0 :         xub_StrLen nTokCount = 1;
      37           0 :         sal_Bool bStart = sal_True;     // Are we on the first character in the Token?
      38           0 :         sal_Bool bInString = sal_False; // Are we WITHIN a (cStrDel delimited) String?
      39             : 
      40             :         // Search for String-end after the first not matching character
      41           0 :         for( xub_StrLen i = 0; i < nLen; ++i )
      42             :         {
      43           0 :             const sal_Unicode cChar = m_sString.GetChar(i);
      44           0 :             if (bStart)
      45             :             {
      46           0 :                 bStart = sal_False;
      47             :                 // First character a String-Delimiter?
      48           0 :                 if ( cChar == cStrDel )
      49             :                 {
      50           0 :                     bInString = sal_True;   // then we are now WITHIN the string!
      51           0 :                     continue;           // skip this character!
      52             :                 }
      53             :             }
      54             : 
      55           0 :             if (bInString)
      56             :             {
      57             :                 // when now the String-Delimiter-character occurs ...
      58           0 :                 if ( cChar == cStrDel )
      59             :                 {
      60           0 :                     if ((i+1 < nLen) && (m_sString.GetChar(i+1) == cStrDel))
      61             :                     {
      62             :                         // double String-Delimter-character:
      63           0 :                         ++i;    // no string-end, skip next character.
      64             :                     }
      65             :                     else
      66             :                     {
      67             :                         // String-End
      68           0 :                         bInString = sal_False;
      69             :                     }
      70             :                 }
      71             :             } // if (bInString)
      72             :             else
      73             :             {
      74             :                 // does the Token-character match, then raise TokCount
      75           0 :                 if ( cChar == cTok )
      76             :                 {
      77           0 :                     ++nTokCount;
      78           0 :                     bStart = sal_True;
      79             :                 }
      80             :             }
      81             :         }
      82             :         //OSL_TRACE("QuotedTokenizedString::nTokCount = %d\n", ((OUtoCStr(::rtl::OUString(nTokCount))) ? (OUtoCStr(::rtl::OUString(nTokCount))):("NULL")) );
      83             : 
      84           0 :         return nTokCount;
      85             :     }
      86             : 
      87             :     //------------------------------------------------------------------
      88           0 :     String QuotedTokenizedString::GetTokenSpecial(xub_StrLen& nStartPos, sal_Unicode cTok, sal_Unicode cStrDel) const
      89             :     {
      90             :         RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "QuotedTokenizedString::GetTokenCount" );
      91           0 :         String aStr;
      92           0 :         const xub_StrLen nLen = m_sString.Len();
      93           0 :         if ( nLen )
      94             :         {
      95           0 :             sal_Bool bInString = (nStartPos < nLen) && (m_sString.GetChar(nStartPos) == cStrDel);   // are we WITHIN a (cStrDel delimited) String?
      96             : 
      97             :             // First character a String-Delimiter?
      98           0 :             if (bInString )
      99           0 :                 ++nStartPos;            // skip this character!
     100           0 :             if ( nStartPos >= nLen )
     101           0 :                 return aStr;
     102             : 
     103           0 :             sal_Unicode* pData = aStr.AllocBuffer( nLen - nStartPos + 1 );
     104           0 :             const sal_Unicode* pStart = pData;
     105             :             // Search until end of string for the first not matching character
     106           0 :             for( xub_StrLen i = nStartPos; i < nLen; ++i )
     107             :             {
     108           0 :                 const sal_Unicode cChar = m_sString.GetChar(i);
     109           0 :                 if (bInString)
     110             :                 {
     111             :                     // when now the String-Delimiter-character occurs ...
     112           0 :                     if ( cChar == cStrDel )
     113             :                     {
     114           0 :                         if ((i+1 < nLen) && (m_sString.GetChar(i+1) == cStrDel))
     115             :                         {
     116             :                             // double String Delimiter-character
     117             :                             // no end of string, skip next character.
     118           0 :                             ++i;
     119           0 :                             *pData++ = m_sString.GetChar(i);    // character belongs to Result-String
     120             :                         }
     121             :                         else
     122             :                         {
     123             :                             //end of String
     124           0 :                             bInString = sal_False;
     125           0 :                             *pData = 0;
     126             :                         }
     127             :                     }
     128             :                     else
     129             :                     {
     130           0 :                         *pData++ = cChar;   // character belongs to Result-String
     131             :                     }
     132             : 
     133             :                 }
     134             :                 else
     135             :                 {
     136             :                     // does the Token-sign match, then raise nTok
     137           0 :                     if ( cChar == cTok )
     138             :                     {
     139             :                         // premature break of loop possible, because we found what we were looking for
     140           0 :                         nStartPos = i+1;
     141           0 :                         break;
     142             :                     }
     143             :                     else
     144             :                     {
     145           0 :                         *pData++ = cChar;   // character belongs to Result-String
     146             :                     }
     147             :                 }
     148             :             } // for( xub_StrLen i = nStartPos; i < nLen; ++i )
     149           0 :             *pData = 0;
     150           0 :             aStr.ReleaseBufferAccess(xub_StrLen(pData - pStart));
     151             :         }
     152           0 :         return aStr;
     153             :     }
     154             : }
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10