LCOV - code coverage report
Current view: top level - connectivity/source/drivers/file - quotedstring.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 47 0.0 %
Date: 2014-04-14 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/ustrbuf.hxx>
      22             : 
      23             : namespace connectivity
      24             : {
      25             : 
      26             :     //= QuotedTokenizedString
      27             : 
      28             : 
      29           0 :     sal_Int32 QuotedTokenizedString::GetTokenCount( sal_Unicode cTok, sal_Unicode cStrDel ) const
      30             :     {
      31             :         SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com QuotedTokenizedString::GetTokenCount" );
      32           0 :         const sal_Int32 nLen = m_sString.getLength();
      33           0 :         if ( !nLen )
      34           0 :             return 0;
      35             : 
      36           0 :         sal_Int32 nTokCount = 1;
      37           0 :         bool bStart = true;     // Are we on the first character in the Token?
      38           0 :         bool bInString = false; // Are we WITHIN a (cStrDel delimited) String?
      39             : 
      40             :         // Search for String-end after the first not matching character
      41           0 :         for( sal_Int32 i = 0; i < nLen; ++i )
      42             :         {
      43           0 :             const sal_Unicode cChar = m_sString[i];
      44           0 :             if (bStart)
      45             :             {
      46           0 :                 bStart = false;
      47             :                 // First character a String-Delimiter?
      48           0 :                 if ( cChar == cStrDel )
      49             :                 {
      50           0 :                     bInString = 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[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 = 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 = true;
      79             :                 }
      80             :             }
      81             :         }
      82             :         //OSL_TRACE("QuotedTokenizedString::nTokCount = %d\n", ((OUtoCStr(OUString(nTokCount))) ? (OUtoCStr(OUString(nTokCount))):("NULL")) );
      83             : 
      84           0 :         return nTokCount;
      85             :     }
      86             : 
      87             : 
      88           0 :     OUString QuotedTokenizedString::GetTokenSpecial(sal_Int32& nStartPos, sal_Unicode cTok, sal_Unicode cStrDel) const
      89             :     {
      90             :         SAL_INFO( "connectivity.drivers", "file Ocke.Janssen@sun.com QuotedTokenizedString::GetTokenCount" );
      91           0 :         const sal_Int32 nLen = m_sString.getLength();
      92           0 :         if ( nLen )
      93             :         {
      94           0 :             bool bInString = (nStartPos < nLen) && (m_sString[nStartPos] == cStrDel);   // are we WITHIN a (cStrDel delimited) String?
      95             : 
      96             :             // First character a String-Delimiter?
      97           0 :             if (bInString )
      98           0 :                 ++nStartPos;            // skip this character!
      99           0 :             if ( nStartPos >= nLen )
     100           0 :                 return OUString();
     101             : 
     102           0 :             OUStringBuffer sBuff( nLen - nStartPos + 1 );
     103             : 
     104             :             // Search until end of string for the first not matching character
     105           0 :             for( sal_Int32 i = nStartPos; i < nLen; ++i )
     106             :             {
     107           0 :                 const sal_Unicode cChar = m_sString[i];
     108           0 :                 if (bInString)
     109             :                 {
     110             :                     // when now the String-Delimiter-character occurs ...
     111           0 :                     if ( cChar == cStrDel )
     112             :                     {
     113           0 :                         if ((i+1 < nLen) && (m_sString[i+1] == cStrDel))
     114             :                         {
     115             :                             // double String Delimiter-character
     116             :                             // no end of string, skip next character.
     117           0 :                             ++i;
     118           0 :                             sBuff.append(m_sString[i]);    // character belongs to Result-String
     119             :                         }
     120             :                         else
     121             :                         {
     122             :                             //end of String
     123           0 :                             bInString = false;
     124             :                         }
     125             :                     }
     126             :                     else
     127             :                     {
     128           0 :                         sBuff.append(cChar);
     129             :                     }
     130             :                 }
     131             :                 else
     132             :                 {
     133             :                     // does the Token-sign match, then raise nTok
     134           0 :                     if ( cChar == cTok )
     135             :                     {
     136             :                         // premature break of loop possible, because we found what we were looking for
     137           0 :                         nStartPos = i+1;
     138           0 :                         break;
     139             :                     }
     140             :                     else
     141             :                     {
     142           0 :                         sBuff.append(cChar);
     143             :                     }
     144             :                 }
     145             :             } // for( sal_Int32 i = nStartPos; i < nLen; ++i )
     146           0 :             return sBuff.makeStringAndClear();
     147             :         }
     148           0 :         return OUString();
     149             :     }
     150             : }
     151             : 
     152             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10