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

Generated by: LCOV version 1.10