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

Generated by: LCOV version 1.11