src/corelib/tools/qstringbuilder.cpp
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtCore module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "qstringbuilder.h"
       
    43 
       
    44 /*!
       
    45     \class QLatin1Literal
       
    46     \internal
       
    47     \reentrant
       
    48     \since 4.6
       
    49 
       
    50     \brief The QLatin1Literal class provides a thin wrapper around string
       
    51     literals used in source code.
       
    52 
       
    53     \ingroup tools
       
    54     \ingroup shared
       
    55     \ingroup string-processing
       
    56 
       
    57 
       
    58     Unlike \c QLatin1String, a \c QLatin1Literal can retrieve its size
       
    59     without iterating over the literal.
       
    60 
       
    61     The main use of \c QLatin1Literal is in conjunction with \c QStringBuilder
       
    62     to reduce the number of reallocations needed to build up a string from
       
    63     smaller chunks.
       
    64 
       
    65     \sa QStringBuilder, QLatin1String, QString, QStringRef
       
    66 */
       
    67 
       
    68 /*! \fn int QLatin1Literal::size() const
       
    69  
       
    70     Returns the number of characters in the literal \e{excluding} the trailing
       
    71     NULL char.
       
    72 */
       
    73 
       
    74 /*! \fn QLatin1Literal::QLatin1Literal(const char str)
       
    75  
       
    76     Constructs a new literal from the string \a str.
       
    77 */
       
    78 
       
    79 /*! \fn const char *QLatin1Literal::data() const
       
    80  
       
    81     Returns a pointer to the first character of the string literal.
       
    82     The string literal is terminated by a NUL character.
       
    83 */
       
    84 
       
    85 /*!
       
    86     \class QStringBuilder
       
    87     \internal
       
    88     \reentrant
       
    89     \since 4.6
       
    90 
       
    91     \brief The QStringBuilder class is a template class that provides a facility to build up QStrings from smaller chunks.
       
    92 
       
    93     \ingroup tools
       
    94     \ingroup shared
       
    95     \ingroup string-processing
       
    96 
       
    97 
       
    98     To build a QString by multiple concatenations, QString::operator+()
       
    99     is typically used. This causes \e{n - 1} reallocations when building
       
   100     a string from \e{n} chunks.
       
   101 
       
   102     QStringBuilder uses expression templates to collect the individual
       
   103     chunks, compute the total size, allocate the required amount of
       
   104     memory for the final QString object, and copy the chunks into the
       
   105     allocated memory.
       
   106 
       
   107     The QStringBuilder class is not to be used explicitly in user
       
   108     code.  Instances of the class are created as return values of the
       
   109     operator%() function, acting on objects of type QString,
       
   110     QLatin1String, QLatin1Literal, QStringRef, QChar, QCharRef,
       
   111     QLatin1Char, and \c char.
       
   112 
       
   113     Concatenating strings with operator%() generally yields better
       
   114     performance then using \c QString::operator+() on the same chunks
       
   115     if there are three or more of them, and performs equally well in other
       
   116     cases.
       
   117 
       
   118     \sa QLatin1Literal, QString
       
   119 */
       
   120 
       
   121 /*! \fn QStringBuilder::QStringBuilder(const A &a, const B &b)
       
   122   Constructs a QStringBuilder from \a a and \a b.
       
   123  */
       
   124 
       
   125 /* \fn QStringBuilder::operator%(const A &a, const B &b)
       
   126 
       
   127     Returns a \c QStringBuilder object that is converted to a QString object
       
   128     when assigned to a variable of QString type or passed to a function that
       
   129     takes a QString parameter.
       
   130 
       
   131     This function is usable with arguments of type \c QString,
       
   132     \c QLatin1String, \c QLatin1Literal, \c QStringRef, 
       
   133     \c QChar, \c QCharRef, \c QLatin1Char, and \c char.
       
   134 */
       
   135 
       
   136 /*! \fn QByteArray QStringBuilder::toLatin1() const
       
   137   Returns a Latin-1 representation of the string as a QByteArray.  The
       
   138   returned byte array is undefined if the string contains non-Latin1
       
   139   characters.
       
   140  */
       
   141 
       
   142 /*! \fn QStringBuilder::operator QString() const
       
   143  
       
   144     Converts the \c QLatin1Literal into a \c QString object.
       
   145 */