ministring.cpp revision e64031e20c39650a7bc902a3e1aba613b9415dee
/* $Id$ */
/** @file
* IPRT - Mini C++ string class.
*
* This is a base for both Utf8Str and other places where IPRT may want to use
* a lean C++ string class.
*/
/*
* Copyright (C) 2007-2009 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
using namespace iprt;
{
if (lenThat)
{
// calls realloc(cbBoth) and sets m_cbAllocated; may throw bad_alloc.
#ifndef RT_EXCEPTIONS_ENABLED
#endif
}
return *this;
}
{
if (c)
{
// allocate in chunks of 20 in case this gets called several times
{
// calls realloc(cbBoth) and sets m_cbAllocated; may throw bad_alloc.
#ifndef RT_EXCEPTIONS_ENABLED
#endif
}
m_psz[m_cbLength] = c;
++m_cbLength;
}
return *this;
}
const
{
const char *pszThis, *p;
)
return p - pszThis;
return npos;
}
const
{
if (n)
{
const char *psz;
{
// walk the UTF-8 characters until where the caller wants to start
while (*psz && i--)
return ret; // return empty string on bad encoding
if (n == npos)
// all the rest:
else
{
i = n;
while (*psz && i--)
return ret; // return empty string on bad encoding
#ifndef RT_EXCEPTIONS_ENABLED
#endif
}
}
}
return ret;
}
{
if (l1 == 0)
return false;
return false;
/** @todo r=bird: If l2 is 0, then m_psz can be NULL and we will crash. See
* also handling of l2 == in startsWith. */
if (cs == CaseSensitive)
else
}
{
if (l1 == 0 || l2 == 0) /** @todo r=bird: this differs from endsWith, and I think other IPRT code. If l2 == 0, it matches anything. */
return false;
return false;
if (cs == CaseSensitive)
else
}
{
/** @todo r-bird: Not checking for NULL strings like startsWith does (and
* endsWith only does half way). */
if (cs == CaseSensitive)
else
}
{
if (!m_psz)
return VERR_NO_DIGITS;
}
{
if (!m_psz)
return VERR_NO_DIGITS;
}