epoc32/include/estring.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@4
     2
// All rights reserved.
williamr@4
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@4
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@4
     7
//
williamr@4
     8
// Initial Contributors:
williamr@4
     9
// Nokia Corporation - initial contribution.
williamr@4
    10
//
williamr@4
    11
// Contributors:
williamr@4
    12
//
williamr@4
    13
// Description:
williamr@4
    14
//
williamr@4
    15
williamr@4
    16
#ifndef ESTRING_H
williamr@4
    17
#define ESTRING_H
williamr@4
    18
williamr@4
    19
#include <e32std.h>
williamr@4
    20
williamr@4
    21
// this macro is defined only if the target is WINSCW and wchar_t is ON
williamr@4
    22
// (i.e OPTION CW -wchar_t on)
williamr@4
    23
// and  if the target is any thing other than WINSCW 
williamr@4
    24
// it is being assumed that wchar_t is ON(OPTION CW -wchar_t on by 
williamr@4
    25
// default or other wise)
williamr@4
    26
#define NATIVE_WCHAR // most platforms do wchar_t properly
williamr@4
    27
#if defined __cplusplus && defined __WINSCW__
williamr@4
    28
#if !__option(wchar_type) // without the wchar_type option
williamr@4
    29
typedef unsigned short wchar_t; // needs a typedef
williamr@4
    30
#undef NATIVE_WCHAR // which is not native
williamr@4
    31
#endif
williamr@4
    32
#endif
williamr@4
    33
williamr@4
    34
// Since the LStrings can leave in their constructors, we have to make
williamr@4
    35
// sure to avoid the operator new/delete ELeave mismatch problem that
williamr@4
    36
// can result in the top level LString object heap being
williamr@4
    37
// leaked. These operator delete overloads match the global operator
williamr@4
    38
// new overloads applicable to the LString classes (which are
williamr@4
    39
// non-CBase derived).
williamr@4
    40
//
williamr@4
    41
// Note that when allocating a native C++ array of LStrings, only the
williamr@4
    42
// default constructor is invoked which cannot leave. So there are no
williamr@4
    43
// issues related to the array case.
williamr@4
    44
williamr@4
    45
#define LSTRING_CONSTRUCTORS_MAY_LEAVE \
williamr@4
    46
	static void operator delete(TAny* aPtr) __NO_THROW \
williamr@4
    47
		{ \
williamr@4
    48
		return ::operator delete(aPtr); \
williamr@4
    49
		} \
williamr@4
    50
	\
williamr@4
    51
	static void operator delete(TAny* aPtr, TLeave) __NO_THROW \
williamr@4
    52
		{ \
williamr@4
    53
		return ::operator delete(aPtr); \
williamr@4
    54
		} \
williamr@4
    55
	\
williamr@4
    56
	static void operator delete(TAny*, TAny*) __NO_THROW \
williamr@4
    57
		{ \
williamr@4
    58
		} 
williamr@4
    59
williamr@4
    60
/**
williamr@4
    61
	@file
williamr@4
    62
williamr@4
    63
	A self-managing descriptor class
williamr@4
    64
williamr@4
    65
   	@publishedAll
williamr@4
    66
   	@released
williamr@4
    67
*/
williamr@4
    68
williamr@4
    69
/**
williamr@4
    70
@class LString8
williamr@4
    71
williamr@4
    72
LString8 is a convenient, general-purpose 8 bit string class derived
williamr@4
    73
from RBuf8. LString8 adds automatic cleanup and on-demand buffer
williamr@4
    74
resize facilities.
williamr@4
    75
williamr@4
    76
@par L-Classes
williamr@4
    77
williamr@4
    78
Note: The L prefix denotes that construction, copying, passing and
williamr@4
    79
returning by value, assignment, and manipulation via operators should
williamr@4
    80
all be considered potentially leaving operations unless otherwise
williamr@4
    81
explicitly documented. Code that uses LString8 should be written
williamr@4
    82
accordingly, in leave-safe style.
williamr@4
    83
williamr@4
    84
@par Descriptor Relationships
williamr@4
    85
williamr@4
    86
Like an RBuf8, an LString8 can be passed to any function that is
williamr@4
    87
prototyped to take a TDes8 or a TDesC8 reference. Again like an
williamr@4
    88
RBuf8, an LString8 maintains its string data in a heap buffer.
williamr@4
    89
williamr@4
    90
@par Value-Type Behaviour
williamr@4
    91
williamr@4
    92
Unlike RBuf8, an LString8 may be used much like a simple T class;
williamr@4
    93
LString8 typed variables will automatically clean up after themselves
williamr@4
    94
when they go out of scope, and LString8 typed fields will similarly
williamr@4
    95
automatically release all owned resources when their containing object
williamr@4
    96
is destroyed.
williamr@4
    97
williamr@4
    98
For example, where:
williamr@4
    99
williamr@4
   100
@code
williamr@4
   101
RBuf8 buf;
williamr@4
   102
buf.CleanupClosePushL();
williamr@4
   103
...
williamr@4
   104
CleanupStack::PopAndDestroy();
williamr@4
   105
@endcode
williamr@4
   106
williamr@4
   107
would be required, with LString8:
williamr@4
   108
williamr@4
   109
@code
williamr@4
   110
LString8 buf;
williamr@4
   111
...
williamr@4
   112
@endcode
williamr@4
   113
williamr@4
   114
will suffice. Pushing an LString8 onto the cleanup stack is not
williamr@4
   115
necessary or recommended, but the effects of doing so are
williamr@4
   116
benign. LString8 instances can also be passed and returned by value,
williamr@4
   117
but note that doing so may trigger implicit heap allocation and cause
williamr@4
   118
a leave with KErrNoMemory.
williamr@4
   119
williamr@4
   120
@code
williamr@4
   121
void TakeString(LString8 aString)
williamr@4
   122
	{
williamr@4
   123
	// ...
williamr@4
   124
	}
williamr@4
   125
williamr@4
   126
LString8 ReturnString(LString8 aString)
williamr@4
   127
	{
williamr@4
   128
	TakeString(aString); // Statement may leave with KErrNoMemory
williamr@4
   129
	return aString; // Statement may leave with KErrNoMemory
williamr@4
   130
	}
williamr@4
   131
@endcode
williamr@4
   132
williamr@4
   133
As with other descriptors, passing by reference when possible is more
williamr@4
   134
efficient.
williamr@4
   135
williamr@4
   136
@par On-Demand Growth
williamr@4
   137
williamr@4
   138
In addition to the value-type semantics described above, LString8
williamr@4
   139
also supports automatic in-place resizing. All standard descriptor
williamr@4
   140
methods are available, but for any non-leaving descriptor method that
williamr@4
   141
may panic due to buffer overflow, LString8 adds a corresponding
williamr@4
   142
leaving method that automatically expands the underlying buffer
williamr@4
   143
on-demand. For example, Append() will panic if the new data overflows
williamr@4
   144
available buffer space, while AppendL() will attempt to realloc the
williamr@4
   145
buffer as necessary. The new leaving variants may therefore leave with
williamr@4
   146
KErrNoMemory, may invalidate any existing raw pointers into the data
williamr@4
   147
buffer (e.g. those previously returned by Ptr()), and may change the
williamr@4
   148
value returned by MaxLength().
williamr@4
   149
williamr@4
   150
@code
williamr@4
   151
LString8 message; // Zero length
williamr@4
   152
message.FormatL(_L("This is message %n from %S"), n, &s); // FormatL automatically grows the buffer
williamr@4
   153
User::InfoPrint(message);
williamr@4
   154
@endcode
williamr@4
   155
williamr@4
   156
It is important to note that LString8 only supports automatic growth
williamr@4
   157
when being manipulated directly as an LString8. When an LString8 is
williamr@4
   158
passed to a function accepting a TDes8, that function will operate on
williamr@4
   159
it as if it is a fixed-max-length descriptor. In that case, adequate
williamr@4
   160
capacity must be reserved within the LString8 prior to calling the
williamr@4
   161
function. This can either be achieved using the appropriate constructor or ReserveFreeCapacityL().
williamr@4
   162
williamr@4
   163
@code
williamr@4
   164
extern void GetLastQuery(TDes8& aQuery);
williamr@4
   165
extern void GetLastAuxQuery(TDes8& aQuery);
williamr@4
   166
williamr@4
   167
LString8 query(KMaxQuerySize); // Guarantees query.MaxLength() >= KMaxQuerySize
williamr@4
   168
GetLastQuery(query);
williamr@4
   169
williamr@4
   170
// ...
williamr@4
   171
williamr@4
   172
previousQueryMaxLength = query.MaxLength(); 
williamr@4
   173
williamr@4
   174
query.ReserveFreeCapacityL(KExtraRequiredSize); // Guarantees query.MaxLength() >= KExtraRequiredSize + previousQueryMaxLength;
williamr@4
   175
GetLastAuxQuery(query);
williamr@4
   176
williamr@4
   177
@endcode
williamr@4
   178
williamr@4
   179
@par Relationship with TDes and RBuf
williamr@4
   180
williamr@4
   181
LString8 derives from RBuf8 in order to achieve maximum
williamr@4
   182
interoperability with existing descriptor-accepting APIs. This
williamr@4
   183
derivation forces some unusual API compromises, however, due to the
williamr@4
   184
unique characteristics of LString8 compared to other descriptors.
williamr@4
   185
williamr@4
   186
Some of the mutating methods on the base classes, TDes8 and RBuf8,
williamr@4
   187
panic when called with insufficient buffer space.  Sufficient space is
williamr@4
   188
a precondition of these base classes which LString8 relaxes with
williamr@4
   189
its capability to start with zero length.  LString8 defines new
williamr@4
   190
leaving variants of these methods with auto-growth behaviour
williamr@4
   191
(e.g. AppendL), but at the same time inherits the original methods
williamr@4
   192
(e.g. Append).  This makes it too easy for developers to call the
williamr@4
   193
wrong method inadvertently. In order to address this, the original 
williamr@4
   194
non-leaving methods have been made private in LString8. Developers 
williamr@4
   195
should use the leaving LString8 versions.
williamr@4
   196
williamr@4
   197
Note that, if required for any reason, the non-leaving method variants 
williamr@4
   198
may be accessed by explicitly qualifying the method name to the 
williamr@4
   199
appropriate parent type. For example: aString.TDes::Append(...). When 
williamr@4
   200
working with an LString8 but doing so via a TDes& typed variable, all 
williamr@4
   201
TDes8 APIs are directly available.
williamr@4
   202
williamr@4
   203
Hiding these methods does not remove the problem entirely.  The same
williamr@4
   204
problem can happen if an LString object of insufficient size in passed
williamr@4
   205
into a any API accepting a TDes. The advice is that developers always
williamr@4
   206
ensure there is sufficient space before passing LString as a TDes.
williamr@4
   207
williamr@4
   208
@par Performance Concerns
williamr@4
   209
williamr@4
   210
While being simpler to use than existing descriptors in many cases,
williamr@4
   211
LString8's use of heap allocation and its resizing variant methods
williamr@4
   212
clearly come with associated costs. Their use in performance-critical
williamr@4
   213
code should be carefully considered. On the other hand, LString8's
williamr@4
   214
small stack footprint and ability to better-handle inputs of
williamr@4
   215
unpredictable size may make them a better choice when the alternative
williamr@4
   216
is a large, fixed-max-size TBuf or HBufC.
williamr@4
   217
williamr@4
   218
@par Buffer Ownership
williamr@4
   219
williamr@4
   220
Typically an LString8 will automatically allocate its own buffer, but
williamr@4
   221
like RBuf8 it can also take ownership of a pre-existing raw memory
williamr@4
   222
buffer or heap descriptor.
williamr@4
   223
williamr@4
   224
The class is intended for instantiation.
williamr@4
   225
williamr@4
   226
@see RBuf8
williamr@4
   227
@see TBuf8
williamr@4
   228
@see TPtr8
williamr@4
   229
@see HBufC8
williamr@4
   230
@see TDesC8
williamr@4
   231
@see TDes8
williamr@4
   232
@see LString
williamr@4
   233
williamr@4
   234
*/
williamr@4
   235
class LString8 : public RBuf8
williamr@4
   236
	{
williamr@4
   237
public:
williamr@4
   238
	/*
williamr@4
   239
	 * We add leaving (auto-resizing) variants of the standard TDes
williamr@4
   240
	 * methods where appropriate, and enhance the behaviour of the
williamr@4
   241
	 * corresponding operators to match
williamr@4
   242
	 */
williamr@4
   243
williamr@4
   244
	LSTRING_CONSTRUCTORS_MAY_LEAVE
williamr@4
   245
williamr@4
   246
	IMPORT_C LString8();
williamr@4
   247
	IMPORT_C ~LString8();
williamr@4
   248
williamr@4
   249
	// Construct with initial capacity
williamr@4
   250
	IMPORT_C explicit LString8(TInt aInitialCapacity);
williamr@4
   251
williamr@4
   252
	// Construct by data copying
williamr@4
   253
	IMPORT_C LString8(const TDesC8& aDes);
williamr@4
   254
	IMPORT_C LString8(const TUint8* aZeroTerminatedString);
williamr@4
   255
	IMPORT_C LString8(const LString8& aDes);
williamr@4
   256
williamr@4
   257
	// Construction thru transfer of ownership
williamr@4
   258
	IMPORT_C explicit LString8(HBufC8* aHBuf);
williamr@4
   259
	IMPORT_C explicit LString8(TUint8 *aHeapCell,TInt aMaxLength);
williamr@4
   260
	IMPORT_C explicit LString8(TUint8 *aHeapCell,TInt aLength,TInt aMaxLength);
williamr@4
   261
williamr@4
   262
	// Assignment thru payload copying
williamr@4
   263
	IMPORT_C LString8& operator=(const TDesC8& aDes);
williamr@4
   264
	IMPORT_C LString8& operator=(const LString8& aDes);
williamr@4
   265
	IMPORT_C LString8& operator=(const TUint8* aZeroTerminatedString);
williamr@4
   266
williamr@4
   267
	// Assignment by transfer of payload to this object;
williamr@4
   268
	// supplied object is destroyed or zeroed.
williamr@4
   269
	IMPORT_C LString8& operator=(HBufC8* aHBuf);
williamr@4
   270
williamr@4
   271
	// Assign by transfer of payload ownership to this object;
williamr@4
   272
	// supplied object is destroyed or zeroed.
williamr@4
   273
	IMPORT_C void Assign(const LString8& aString);
williamr@4
   274
	IMPORT_C void Assign(const RBuf8& aRBuf);
williamr@4
   275
	IMPORT_C void Assign(HBufC8* aHBuf);
williamr@4
   276
	IMPORT_C void Assign(TUint8 *aHeapCell,TInt aMaxLength);
williamr@4
   277
	IMPORT_C void Assign(TUint8 *aHeapCell,TInt aLength,TInt aMaxLength);
williamr@4
   278
williamr@4
   279
	IMPORT_C void CreateL(RReadStream& aStream,TInt aMaxLength);
williamr@4
   280
williamr@4
   281
	IMPORT_C LString8& operator+=(TChar aChar);
williamr@4
   282
	IMPORT_C LString8& operator+=(const TDesC8 &aDes);
williamr@4
   283
williamr@4
   284
	IMPORT_C void CopyL(const TDesC8 &aDes);
williamr@4
   285
	IMPORT_C void CopyL(const TDesC16 &aDes);
williamr@4
   286
	IMPORT_C void CopyL(const TUint8 *aZeroTerminatedString);
williamr@4
   287
	IMPORT_C void CopyL(const TUint8 *aBuf,TInt aLength);
williamr@4
   288
williamr@4
   289
 	IMPORT_C void SetLengthL(TInt aLength);
williamr@4
   290
 	IMPORT_C void SetMaxLengthL(TInt aMaxLength);
williamr@4
   291
	IMPORT_C void Compress(); // deprecated; to be removed
williamr@4
   292
	IMPORT_C void ReserveFreeCapacityL(TInt aExtraSpaceLength);
williamr@4
   293
	IMPORT_C void Reset();
williamr@4
   294
williamr@4
   295
	IMPORT_C void AppendL(TChar aChar);
williamr@4
   296
	IMPORT_C void AppendL(const TDesC8 &aDes);
williamr@4
   297
	IMPORT_C void AppendL(const TUint8 *aBuf,TInt aLength);
williamr@4
   298
williamr@4
   299
	IMPORT_C void FillL(TChar aChar,TInt aLength);
williamr@4
   300
	IMPORT_C void FillZL(TInt aLength);
williamr@4
   301
williamr@4
   302
	IMPORT_C void NumFixedWidthL(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   303
	IMPORT_C void AppendNumFixedWidthL(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   304
	IMPORT_C const TUint8 *PtrZL();
williamr@4
   305
	IMPORT_C void CopyFL(const TDesC8 &aDes);
williamr@4
   306
	IMPORT_C void CopyCL(const TDesC8 &aDes);
williamr@4
   307
	IMPORT_C void CopyLCL(const TDesC8 &aDes);
williamr@4
   308
	IMPORT_C void CopyUCL(const TDesC8 &aDes);
williamr@4
   309
	IMPORT_C void CopyCPL(const TDesC8 &aDes);
williamr@4
   310
	IMPORT_C void AppendFillL(TChar aChar,TInt aLength);
williamr@4
   311
	IMPORT_C void ZeroTerminateL();
williamr@4
   312
	IMPORT_C void SwapL(TDes8 &aDes);
williamr@4
   313
	IMPORT_C void SwapL(LString8 &aDes); // Added overload
williamr@4
   314
	IMPORT_C void InsertL(TInt aPos,const TDesC8 &aDes);
williamr@4
   315
	IMPORT_C void ReplaceL(TInt aPos,TInt aLength,const TDesC8 &aDes);
williamr@4
   316
	IMPORT_C void JustifyL(const TDesC8 &aDes,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   317
	IMPORT_C void NumFixedWidthUCL(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   318
	IMPORT_C void NumUCL(TUint64 aVal, TRadix aRadix=EDecimal);
williamr@4
   319
	IMPORT_C TInt NumL(TReal aVal,const TRealFormat &aFormat) __SOFTFP;
williamr@4
   320
	IMPORT_C void NumL(TInt64 aVal);
williamr@4
   321
	IMPORT_C void NumL(TUint64 aVal, TRadix aRadix);
williamr@4
   322
	IMPORT_C void FormatL(TRefByValue<const TDesC8> aFmt,...);
williamr@4
   323
	IMPORT_C void FormatListL(const TDesC8 &aFmt,VA_LIST aList);
williamr@4
   324
	IMPORT_C void AppendJustifyL(const TDesC8 &Des,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   325
	IMPORT_C void AppendJustifyL(const TDesC8 &Des,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   326
	IMPORT_C void AppendJustifyL(const TUint8 *aZeroTerminatedString,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   327
	IMPORT_C void AppendJustifyL(const TUint8 *aString,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   328
	IMPORT_C void AppendNumFixedWidthUCL(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   329
	IMPORT_C void AppendNumUCL(TUint64 aVal, TRadix aRadix=EDecimal);
williamr@4
   330
	IMPORT_C TInt AppendNumL(TReal aVal,const TRealFormat &aFormat) __SOFTFP;
williamr@4
   331
	IMPORT_C void AppendNumL(TInt64 aVal);
williamr@4
   332
	IMPORT_C void AppendNumL(TUint64 aVal, TRadix aRadix);
williamr@4
   333
	IMPORT_C void AppendFormatL(TRefByValue<const TDesC8> aFmt,...);
williamr@4
   334
	IMPORT_C void AppendFormatListL(const TDesC8 &aFmt,VA_LIST aList);
williamr@4
   335
	
williamr@4
   336
	using RBuf8::operator==;
williamr@4
   337
	IMPORT_C TBool operator==( const TUint8* aZeroTerminatedString) const;
williamr@4
   338
	using RBuf8::operator<;
williamr@4
   339
	IMPORT_C TBool operator<( const TUint8* aZeroTerminatedString) const;
williamr@4
   340
	using RBuf8::operator<=;
williamr@4
   341
	IMPORT_C TBool operator<=( const TUint8* aZeroTerminatedString) const;
williamr@4
   342
	using RBuf8::operator>;
williamr@4
   343
	IMPORT_C TBool operator>( const TUint8* aZeroTerminatedString) const;
williamr@4
   344
	using RBuf8::operator>=;
williamr@4
   345
	IMPORT_C TBool operator>=( const TUint8* aZeroTerminatedString) const;
williamr@4
   346
	using RBuf8::operator!=;
williamr@4
   347
	IMPORT_C TBool operator!=( const TUint8* aZeroTerminatedString) const;
williamr@4
   348
	using RBuf8::Compare;
williamr@4
   349
	IMPORT_C TInt Compare(const TUint8* aZeroTerminatedString) const;
williamr@4
   350
	using RBuf8::CompareF;
williamr@4
   351
	IMPORT_C TInt CompareF(const TUint8* aZeroTerminatedString) const;
williamr@4
   352
	using RBuf8::Match;
williamr@4
   353
	IMPORT_C TInt Match(const TUint8* aZeroTerminatedString) const;
williamr@4
   354
	using RBuf8::MatchF;
williamr@4
   355
	IMPORT_C TInt MatchF(const TUint8* aZeroTerminatedString) const;
williamr@4
   356
	using RBuf8::Find;
williamr@4
   357
	IMPORT_C TInt Find(const TUint8* aZeroTerminatedString) const;
williamr@4
   358
	using RBuf8::FindF;
williamr@4
   359
	IMPORT_C TInt FindF(const TUint8* aZeroTerminatedString) const;
williamr@4
   360
williamr@4
   361
	IMPORT_C void CopyFL(const TUint8* aZeroTerminatedString);
williamr@4
   362
	IMPORT_C void CopyLCL(const TUint8* aZeroTerminatedString);
williamr@4
   363
	IMPORT_C void CopyUCL(const TUint8* aZeroTerminatedString);
williamr@4
   364
	IMPORT_C void CopyCPL(const TUint8* aZeroTerminatedString);
williamr@4
   365
	IMPORT_C void InsertL(TInt aPos,const TUint8* aZeroTerminatedString);
williamr@4
   366
	IMPORT_C void ReplaceL(TInt aPos,TInt aLength,const TUint8* aZeroTerminatedString);
williamr@4
   367
	IMPORT_C void JustifyL(const TUint8* aZeroTerminatedString,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   368
	IMPORT_C void AppendL(const TUint8* aZeroTerminatedString);
williamr@4
   369
	IMPORT_C LString8& operator+=(const TUint8* aZeroTerminatedString);
williamr@4
   370
	
williamr@4
   371
	IMPORT_C LString8(const char* aCharStr);
williamr@4
   372
	
williamr@4
   373
	IMPORT_C TBool operator==( const char* aCharStr) const;
williamr@4
   374
	IMPORT_C TBool operator<( const char* aCharStr) const;
williamr@4
   375
	IMPORT_C TBool operator<=( const char* aCharStr) const;
williamr@4
   376
	IMPORT_C TBool operator>( const char* aCharStr) const;
williamr@4
   377
	IMPORT_C TBool operator>=( const char* aCharStr) const;
williamr@4
   378
	IMPORT_C TBool operator!=( const char* aCharStr) const;
williamr@4
   379
	IMPORT_C TInt Compare(const char* aCharStr) const;
williamr@4
   380
	IMPORT_C TInt CompareF(const char* aCharStr) const;
williamr@4
   381
	IMPORT_C TInt Match(const char* aCharStr) const;
williamr@4
   382
	IMPORT_C TInt MatchF(const char* aCharStr) const;
williamr@4
   383
	IMPORT_C TInt Find(const char* aCharStr) const;
williamr@4
   384
	IMPORT_C TInt Find(const char* aCharStr,TInt aLenS ) const;
williamr@4
   385
	IMPORT_C TInt FindF(const char* aCharStr) const;
williamr@4
   386
	IMPORT_C TInt FindF(const char* aCharStr,TInt aLenS) const;
williamr@4
   387
		
williamr@4
   388
	IMPORT_C LString8& operator=(const char* aCharStr);
williamr@4
   389
	IMPORT_C LString8& operator+=(const char* aCharStr);
williamr@4
   390
	IMPORT_C void CopyL(const char* aCharStr);
williamr@4
   391
	IMPORT_C void CopyFL(const char* aCharStr);
williamr@4
   392
	IMPORT_C void CopyLCL(const char* aCharStr);
williamr@4
   393
	IMPORT_C void CopyUCL(const char* aCharStr);
williamr@4
   394
	IMPORT_C void CopyCPL(const char* aCharStr);
williamr@4
   395
	IMPORT_C void InsertL(TInt aPos,const char* aCharStr);
williamr@4
   396
	IMPORT_C void ReplaceL(TInt aPos,TInt aLength,const char* aCharStr);
williamr@4
   397
	IMPORT_C void AppendL(const char* aCharStr, TInt aLength);
williamr@4
   398
	IMPORT_C void AppendL(const char *aCharStr );
williamr@4
   399
	IMPORT_C void JustifyL(const char* aCharStr,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   400
	IMPORT_C void AppendJustifyL(const char* aCharStr,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   401
	IMPORT_C void AppendJustifyL(const char* aCharStr,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   402
williamr@4
   403
protected:
williamr@4
   404
williamr@4
   405
private:
williamr@4
   406
	/*
williamr@4
   407
	 * capacity management methods
williamr@4
   408
	 */
williamr@4
   409
	void ReserveL(TInt aMinRequiredCapacity);
williamr@4
   410
	void ReserveCapacityGrowExponentialL(TInt aRequiredCapacity);
williamr@4
   411
	void ReserveCapacityGrowExponentialL();
williamr@4
   412
	void ReserveFreeCapacityGrowExponentialL(TInt aRequiredEmptySpace);
williamr@4
   413
	
williamr@4
   414
williamr@4
   415
	//----------------------------------------------------------
williamr@4
   416
	// These mutable TDes8 methods panic when called with an insufficient
williamr@4
   417
	// buffer space.
williamr@4
   418
	// A precondition for TDes8 use is that a sufficient
williamr@4
   419
	// sufficient buffer is allocated before making calls that write to the
williamr@4
   420
	// buffer. LString invalidates this precondition.
williamr@4
   421
	// LString inheriting these TDes methods makes it easy
williamr@4
   422
	// for developers to call them inadvertently. They have been made
williamr@4
   423
	// private to ensure the misunderstanding never happens. Developers should
williamr@4
   424
	// use the leaving (L suffixed) LString equivalents.
williamr@4
   425
	void SetLength(TInt aLength);
williamr@4
   426
	void SetMax();
williamr@4
   427
	void Copy(const TDesC8 &aDes);
williamr@4
   428
	void Copy(const TDesC16 &aDes);
williamr@4
   429
	void Copy(const TUint8 *aBuf,TInt aLength);
williamr@4
   430
	void Copy(const TUint8 *aString);
williamr@4
   431
	void Append(TChar aChar);
williamr@4
   432
	void Append(const TDesC8 &aDes);
williamr@4
   433
	void Append(const TUint8 *aBuf,TInt aLength);
williamr@4
   434
	void Fill(TChar aChar,TInt aLength);
williamr@4
   435
	void FillZ(TInt aLength);
williamr@4
   436
	void NumFixedWidth(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   437
	void AppendNumFixedWidth(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   438
	const TUint8 *PtrZ();
williamr@4
   439
	void CopyF(const TDesC8 &aDes);
williamr@4
   440
	void CopyC(const TDesC8 &aDes);
williamr@4
   441
	void CopyLC(const TDesC8 &aDes);
williamr@4
   442
	void CopyUC(const TDesC8 &aDes);
williamr@4
   443
	void CopyCP(const TDesC8 &aDes);
williamr@4
   444
	void AppendFill(TChar aChar,TInt aLength);
williamr@4
   445
	void ZeroTerminate();
williamr@4
   446
	void Swap(TDes8 &aDes);
williamr@4
   447
	void Insert(TInt aPos,const TDesC8 &aDes);
williamr@4
   448
	void Replace(TInt aPos,TInt aLength,const TDesC8 &aDes);
williamr@4
   449
	void Justify(const TDesC8 &aDes,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   450
	void NumFixedWidthUC(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   451
	void NumUC(TUint64 aVal, TRadix aRadix=EDecimal);
williamr@4
   452
	TInt Num(TReal aVal,const TRealFormat &aFormat) __SOFTFP;
williamr@4
   453
	void Num(TInt64 aVal);
williamr@4
   454
	void Num(TUint64 aVal, TRadix aRadix);
williamr@4
   455
	void Format(TRefByValue<const TDesC8> aFmt,...);
williamr@4
   456
	void FormatList(const TDesC8 &aFmt,VA_LIST aList);
williamr@4
   457
	void AppendJustify(const TDesC8 &Des,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   458
	void AppendJustify(const TDesC8 &Des,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   459
	void AppendJustify(const TUint8 *aZeroTerminatedString,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   460
	void AppendJustify(const TUint8 *aZeroTerminatedString,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   461
	void AppendNumFixedWidthUC(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   462
	void AppendNumUC(TUint64 aVal, TRadix aRadix=EDecimal);
williamr@4
   463
	TInt AppendNum(TReal aVal,const TRealFormat &aFormat) __SOFTFP;
williamr@4
   464
	void AppendNum(TInt64 aVal);
williamr@4
   465
	void AppendNum(TUint64 aVal, TRadix aRadix);
williamr@4
   466
	void AppendFormat(TRefByValue<const TDesC8> aFmt,TDes8Overflow *aOverflowHandler,...);
williamr@4
   467
	void AppendFormat(TRefByValue<const TDesC8> aFmt,...);
williamr@4
   468
	void AppendFormatList(const TDesC8 &aFmt,VA_LIST aList,TDes8Overflow *aOverflowHandler=NULL);
williamr@4
   469
	// end of TDes8 methods
williamr@4
   470
	//---------------------------------------------------
williamr@4
   471
williamr@4
   472
	//----------------------------------------------------------
williamr@4
   473
	// These mutable RBuf8 methods have been privatised because
williamr@4
   474
	// they make assumptions which are incompatible with the 
williamr@4
   475
	// general use pattern of LString16.
williamr@4
   476
	void Swap(RBuf8& aRBuf);
williamr@4
   477
	TInt Create(TInt aMaxLength);
williamr@4
   478
	void CreateL(TInt aMaxLength);
williamr@4
   479
	TInt CreateMax(TInt aMaxLength);
williamr@4
   480
	void CreateMaxL(TInt aMaxLength);
williamr@4
   481
	TInt Create(const TDesC8& aDes);
williamr@4
   482
	void CreateL(const TDesC8& aDes);
williamr@4
   483
	TInt Create(const TDesC8& aDes,TInt aMaxLength);
williamr@4
   484
	void CreateL(const TDesC8& aDes,TInt aMaxLength);
williamr@4
   485
	void Close();
williamr@4
   486
	void CleanupClosePushL();
williamr@4
   487
	// end of privated RBuf16 methods
williamr@4
   488
	//---------------------------------------------------
williamr@4
   489
williamr@4
   490
	void EnsureCapacityIncrementL(TInt aLengthIncrement);
williamr@4
   491
	void IncreaseCapacityL();
williamr@4
   492
	
williamr@4
   493
private:
williamr@4
   494
	//reserved data member for future-proofing
williamr@4
   495
	TInt iReserved;
williamr@4
   496
	};
williamr@4
   497
williamr@4
   498
/**
williamr@4
   499
This is the 16-bit version of LString8. All the comments on LString8 apply equally.
williamr@4
   500
williamr@4
   501
@see LString8
williamr@4
   502
@see RBuf16
williamr@4
   503
@see TBuf16
williamr@4
   504
@see TPtr16
williamr@4
   505
@see HBufC16
williamr@4
   506
@see TDesC16
williamr@4
   507
@see TDes16
williamr@4
   508
@see LString
williamr@4
   509
*/
williamr@4
   510
class LString16 : public RBuf16
williamr@4
   511
	{
williamr@4
   512
public:
williamr@4
   513
	/*
williamr@4
   514
	 * We add leaving (auto-resizing) variants of the standard TDes
williamr@4
   515
	 * methods where appropriate, and enhance the behaviour of the
williamr@4
   516
	 * corresponding operators to match
williamr@4
   517
	 */
williamr@4
   518
williamr@4
   519
	LSTRING_CONSTRUCTORS_MAY_LEAVE
williamr@4
   520
williamr@4
   521
	IMPORT_C LString16();
williamr@4
   522
	IMPORT_C ~LString16();
williamr@4
   523
williamr@4
   524
	// Construct with initial capacity
williamr@4
   525
	IMPORT_C explicit LString16(TInt aInitialCapacity);
williamr@4
   526
williamr@4
   527
	// Construct by data copying
williamr@4
   528
	IMPORT_C LString16(const TDesC16& aDes);
williamr@4
   529
	IMPORT_C LString16(const TUint16* aZeroTerminatedString);
williamr@4
   530
	IMPORT_C LString16(const LString16& aDes);
williamr@4
   531
williamr@4
   532
	// Construction thru transfer of ownership
williamr@4
   533
	IMPORT_C explicit LString16(HBufC16* aHBuf);
williamr@4
   534
	IMPORT_C explicit LString16(TUint16 *aHeapCell,TInt aMaxLength);
williamr@4
   535
	IMPORT_C explicit LString16(TUint16 *aHeapCell,TInt aLength,TInt aMaxLength);
williamr@4
   536
williamr@4
   537
	// Assignment thru payload copying
williamr@4
   538
	IMPORT_C LString16& operator=(const TDesC16& aDes);
williamr@4
   539
	IMPORT_C LString16& operator=(const LString16& aDes);
williamr@4
   540
	IMPORT_C LString16& operator=(const TUint16* aZeroTerminatedString);
williamr@4
   541
williamr@4
   542
	// Assignment by transfer of payload to this object;
williamr@4
   543
	// supplied object is destroyed or zeroed.
williamr@4
   544
	IMPORT_C LString16& operator=(HBufC16* aHBuf);
williamr@4
   545
williamr@4
   546
	// Assign by transfer of payload ownership to this object;
williamr@4
   547
	// supplied object is destroyed or zeroed.
williamr@4
   548
	IMPORT_C void Assign(const LString16& aString);
williamr@4
   549
	IMPORT_C void Assign(const RBuf16& aRBuf);
williamr@4
   550
	IMPORT_C void Assign(HBufC16* aHBuf);
williamr@4
   551
	IMPORT_C void Assign(TUint16 *aHeapCell,TInt aMaxLength);
williamr@4
   552
	IMPORT_C void Assign(TUint16 *aHeapCell,TInt aLength,TInt aMaxLength);
williamr@4
   553
williamr@4
   554
	IMPORT_C void CreateL(RReadStream& aStream,TInt aMaxLength);
williamr@4
   555
williamr@4
   556
	IMPORT_C LString16& operator+=(TChar aChar);
williamr@4
   557
	IMPORT_C LString16& operator+=(const TDesC16 &aDes);
williamr@4
   558
williamr@4
   559
	IMPORT_C void CopyL(const TDesC16 &aDes);
williamr@4
   560
	IMPORT_C void CopyL(const TUint16 *aZeroTerminatedString);
williamr@4
   561
	IMPORT_C void CopyL(const TDesC8 &aDes);
williamr@4
   562
	IMPORT_C void CopyL(const TUint16 *aBuf,TInt aLength);
williamr@4
   563
williamr@4
   564
 	IMPORT_C void SetLengthL(TInt aLength);
williamr@4
   565
 	IMPORT_C void SetMaxLengthL(TInt aMaxLength);
williamr@4
   566
	IMPORT_C void Compress(); // deprecated; to be removed
williamr@4
   567
	IMPORT_C void ReserveFreeCapacityL(TInt aExtraSpaceLength);
williamr@4
   568
	IMPORT_C void Reset();
williamr@4
   569
williamr@4
   570
	IMPORT_C void AppendL(TChar aChar);
williamr@4
   571
	IMPORT_C void AppendL(const TDesC16 &aDes);
williamr@4
   572
	IMPORT_C void AppendL(const TUint16 *aBuf,TInt aLength);
williamr@4
   573
williamr@4
   574
	IMPORT_C void FillL(TChar aChar,TInt aLength);
williamr@4
   575
	IMPORT_C void FillZL(TInt aLength);
williamr@4
   576
williamr@4
   577
	IMPORT_C void NumFixedWidthL(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   578
	IMPORT_C void AppendNumFixedWidthL(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   579
	IMPORT_C const TUint16 *PtrZL();
williamr@4
   580
	IMPORT_C void CopyFL(const TDesC16 &aDes);
williamr@4
   581
	IMPORT_C void CopyCL(const TDesC16 &aDes);
williamr@4
   582
	IMPORT_C void CopyLCL(const TDesC16 &aDes);
williamr@4
   583
	IMPORT_C void CopyUCL(const TDesC16 &aDes);
williamr@4
   584
	IMPORT_C void CopyCPL(const TDesC16 &aDes);
williamr@4
   585
	IMPORT_C void AppendFillL(TChar aChar,TInt aLength);
williamr@4
   586
	IMPORT_C void ZeroTerminateL();
williamr@4
   587
	IMPORT_C void SwapL(TDes16 &aDes);
williamr@4
   588
	IMPORT_C void SwapL(LString16 &aDes); // Added overload
williamr@4
   589
	IMPORT_C void InsertL(TInt aPos,const TDesC16 &aDes);
williamr@4
   590
	IMPORT_C void ReplaceL(TInt aPos,TInt aLength,const TDesC16 &aDes);
williamr@4
   591
	IMPORT_C void JustifyL(const TDesC16 &aDes,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   592
	IMPORT_C void NumFixedWidthUCL(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   593
	IMPORT_C void NumUCL(TUint64 aVal, TRadix aRadix=EDecimal);
williamr@4
   594
	IMPORT_C TInt NumL(TReal aVal,const TRealFormat &aFormat) __SOFTFP;
williamr@4
   595
	IMPORT_C void NumL(TInt64 aVal);
williamr@4
   596
	IMPORT_C void NumL(TUint64 aVal, TRadix aRadix);
williamr@4
   597
	IMPORT_C void FormatL(TRefByValue<const TDesC16> aFmt,...);
williamr@4
   598
	IMPORT_C void FormatListL(const TDesC16 &aFmt,VA_LIST aList);
williamr@4
   599
	IMPORT_C void AppendJustifyL(const TDesC16 &Des,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   600
	IMPORT_C void AppendJustifyL(const TDesC16 &Des,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   601
	IMPORT_C void AppendJustifyL(const TUint16 *aZeroTerminatedString,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   602
	IMPORT_C void AppendJustifyL(const TUint16 *aString,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   603
	IMPORT_C void AppendNumFixedWidthUCL(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   604
	IMPORT_C void AppendNumUCL(TUint64 aVal, TRadix aRadix=EDecimal);
williamr@4
   605
	IMPORT_C TInt AppendNumL(TReal aVal,const TRealFormat &aFormat) __SOFTFP;
williamr@4
   606
	IMPORT_C void AppendNumL(TInt64 aVal);
williamr@4
   607
	IMPORT_C void AppendNumL(TUint64 aVal, TRadix aRadix);
williamr@4
   608
	IMPORT_C void AppendFormatL(TRefByValue<const TDesC16> aFmt,...);
williamr@4
   609
	IMPORT_C void AppendFormatListL(const TDesC16 &aFmt,VA_LIST aList);
williamr@4
   610
	
williamr@4
   611
	using RBuf16::operator==;
williamr@4
   612
	IMPORT_C TBool operator==( const TUint16* aZeroTerminatedString) const;
williamr@4
   613
	using RBuf16::operator<;
williamr@4
   614
	IMPORT_C TBool operator<( const TUint16* aZeroTerminatedString) const;
williamr@4
   615
	using RBuf16::operator<=;
williamr@4
   616
	IMPORT_C TBool operator<=( const TUint16* aZeroTerminatedString) const;
williamr@4
   617
	using RBuf16::operator>;
williamr@4
   618
	IMPORT_C TBool operator>( const TUint16* aZeroTerminatedString) const;
williamr@4
   619
	using RBuf16::operator>=;
williamr@4
   620
	IMPORT_C TBool operator>=( const TUint16* aZeroTerminatedString) const;
williamr@4
   621
	using RBuf16::operator!=;
williamr@4
   622
	IMPORT_C TBool operator!=( const TUint16* aZeroTerminatedString) const;
williamr@4
   623
	using RBuf16::Compare;
williamr@4
   624
	IMPORT_C TInt Compare(const TUint16* aZeroTerminatedString) const;
williamr@4
   625
	using RBuf16::CompareF;
williamr@4
   626
	IMPORT_C TInt CompareF(const TUint16* aZeroTerminatedString) const;
williamr@4
   627
	using RBuf16::Match;
williamr@4
   628
	IMPORT_C TInt Match(const TUint16* aZeroTerminatedString) const;
williamr@4
   629
	using RBuf16::MatchF;
williamr@4
   630
	IMPORT_C TInt MatchF(const TUint16* aZeroTerminatedString) const;
williamr@4
   631
	using RBuf16::Find;
williamr@4
   632
	IMPORT_C TInt Find(const TUint16* aZeroTerminatedString) const;
williamr@4
   633
	using RBuf16::FindF;
williamr@4
   634
	IMPORT_C TInt FindF(const TUint16* aZeroTerminatedString) const;
williamr@4
   635
	
williamr@4
   636
	IMPORT_C void CopyFL(const TUint16* aZeroTerminatedString);
williamr@4
   637
	IMPORT_C void CopyLCL(const TUint16* aZeroTerminatedString);
williamr@4
   638
	IMPORT_C void CopyUCL(const TUint16* aZeroTerminatedString);
williamr@4
   639
	IMPORT_C void CopyCPL(const TUint16* aZeroTerminatedString);
williamr@4
   640
	IMPORT_C void InsertL(TInt aPos,const TUint16* aZeroTerminatedString);
williamr@4
   641
	IMPORT_C void ReplaceL(TInt aPos,TInt aLength,const TUint16* aZeroTerminatedString);
williamr@4
   642
	IMPORT_C void JustifyL(const TUint16* aZeroTerminatedString,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   643
	IMPORT_C void AppendL(const TUint16* aZeroTerminatedString);
williamr@4
   644
	IMPORT_C LString16& operator+=(const TUint16* aZeroTerminatedString);
williamr@4
   645
	
williamr@4
   646
#ifdef NATIVE_WCHAR 
williamr@4
   647
	IMPORT_C LString16(const wchar_t* aWideCharStr);
williamr@4
   648
	
williamr@4
   649
	IMPORT_C TBool operator==( const wchar_t* aWideCharStr) const;
williamr@4
   650
	IMPORT_C TBool operator<( const wchar_t* aWideCharStr) const;
williamr@4
   651
	IMPORT_C TBool operator<=( const wchar_t* aWideCharStr) const;
williamr@4
   652
	IMPORT_C TBool operator>( const wchar_t* aWideCharStr) const;
williamr@4
   653
	IMPORT_C TBool operator>=( const wchar_t* aWideCharStr) const;
williamr@4
   654
	IMPORT_C TBool operator!=( const wchar_t* aWideCharStr) const;
williamr@4
   655
	IMPORT_C TInt Compare(const wchar_t* aWideCharStr) const;
williamr@4
   656
	IMPORT_C TInt CompareF(const wchar_t* aWideCharStr) const;
williamr@4
   657
	IMPORT_C TInt Match(const wchar_t* aWideCharStr) const;
williamr@4
   658
	IMPORT_C TInt MatchF(const wchar_t* aWideCharStr) const;
williamr@4
   659
	IMPORT_C TInt Find(const wchar_t* aWideCharStr) const;	
williamr@4
   660
	IMPORT_C TInt Find(const wchar_t* aWideCharStr,TInt aLenS ) const;
williamr@4
   661
	IMPORT_C TInt FindF(const wchar_t* aWideCharStr) const;
williamr@4
   662
	IMPORT_C TInt FindF(const wchar_t* aWideCharStr,TInt aLenS) const;
williamr@4
   663
	
williamr@4
   664
	IMPORT_C LString16& operator=(const wchar_t* aWideCharStr);
williamr@4
   665
	IMPORT_C LString16& operator+=(const wchar_t* aWideCharStr);
williamr@4
   666
	IMPORT_C void CopyL(const wchar_t* aWideCharStr);
williamr@4
   667
	IMPORT_C void CopyFL(const wchar_t* aWideCharStr);
williamr@4
   668
	IMPORT_C void CopyLCL(const wchar_t* aWideCharStr);
williamr@4
   669
	IMPORT_C void CopyUCL(const wchar_t* aWideCharStr);
williamr@4
   670
	IMPORT_C void CopyCPL(const wchar_t* aWideCharStr);
williamr@4
   671
	IMPORT_C void InsertL(TInt aPos,const wchar_t* aWideCharStr);
williamr@4
   672
	IMPORT_C void ReplaceL(TInt aPos,TInt aLength,const wchar_t* aWideCharStr);
williamr@4
   673
	IMPORT_C void AppendL(const wchar_t* aWideCharStr, TInt aLength);
williamr@4
   674
	IMPORT_C void AppendL(const wchar_t* aWideCharStr);
williamr@4
   675
	IMPORT_C void JustifyL(const wchar_t* aWideCharStr,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   676
	IMPORT_C void AppendJustifyL(const wchar_t* aWideCharStr,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   677
	IMPORT_C void AppendJustifyL(const wchar_t* aWideCharStr,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   678
	
williamr@4
   679
#endif// NATIVE_WCHAR 
williamr@4
   680
	
williamr@4
   681
williamr@4
   682
protected:
williamr@4
   683
williamr@4
   684
private:
williamr@4
   685
	/*
williamr@4
   686
	 * New capacity management API
williamr@4
   687
	 */
williamr@4
   688
	void ReserveL(TInt aMinRequiredCapacity);
williamr@4
   689
	void ReserveCapacityGrowExponentialL(TInt aRequiredCapacity);
williamr@4
   690
	void ReserveCapacityGrowExponentialL();
williamr@4
   691
	void ReserveFreeCapacityGrowExponentialL(TInt aRequiredEmptySpace);
williamr@4
   692
	
williamr@4
   693
williamr@4
   694
	//----------------------------------------------------------
williamr@4
   695
	// These mutable TDes16 methods panic when called with an insufficient
williamr@4
   696
	// buffer space.
williamr@4
   697
	// A precondition for TDes16 use is that a sufficient
williamr@4
   698
	// sufficient buffer is allocated before making calls that write to the
williamr@4
   699
	// buffer. LString invalidates this precondition.
williamr@4
   700
	// LString inheriting these TDes methods makes it easy
williamr@4
   701
	// for developers to call them inadvertently. They have been made
williamr@4
   702
	// private to ensure the misunderstanding never happens. Developers should
williamr@4
   703
	// use the leaving (L suffixed) LString equivalents.
williamr@4
   704
	void SetLength(TInt aLength);
williamr@4
   705
	void SetMax();
williamr@4
   706
	void Copy(const TDesC8 &aDes);
williamr@4
   707
	void Copy(const TDesC16 &aDes);
williamr@4
   708
	void Copy(const TUint16 *aBuf,TInt aLength);
williamr@4
   709
	void Copy(const TUint16 *aString);
williamr@4
   710
	void Append(TChar aChar);
williamr@4
   711
	void Append(const TDesC16 &aDes);
williamr@4
   712
	void Append(const TUint16 *aBuf,TInt aLength);
williamr@4
   713
	void Fill(TChar aChar,TInt aLength);
williamr@4
   714
	void FillZ(TInt aLength);
williamr@4
   715
	void NumFixedWidth(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   716
	void AppendNumFixedWidth(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   717
	const TUint16 *PtrZ();
williamr@4
   718
	void CopyF(const TDesC16 &aDes);
williamr@4
   719
	void CopyC(const TDesC16 &aDes);
williamr@4
   720
	void CopyLC(const TDesC16 &aDes);
williamr@4
   721
	void CopyUC(const TDesC16 &aDes);
williamr@4
   722
	void CopyCP(const TDesC16 &aDes);
williamr@4
   723
	void AppendFill(TChar aChar,TInt aLength);
williamr@4
   724
	void ZeroTerminate();
williamr@4
   725
	void Swap(TDes16 &aDes);
williamr@4
   726
	void Insert(TInt aPos,const TDesC16 &aDes);
williamr@4
   727
	void Replace(TInt aPos,TInt aLength,const TDesC16 &aDes);
williamr@4
   728
	void Justify(const TDesC16 &aDes,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   729
	void NumFixedWidthUC(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   730
	void NumUC(TUint64 aVal, TRadix aRadix=EDecimal);
williamr@4
   731
	TInt Num(TReal aVal,const TRealFormat &aFormat) __SOFTFP;
williamr@4
   732
	void Num(TInt64 aVal);
williamr@4
   733
	void Num(TUint64 aVal, TRadix aRadix);
williamr@4
   734
	void Format(TRefByValue<const TDesC16> aFmt,...);
williamr@4
   735
	void FormatList(const TDesC16 &aFmt,VA_LIST aList);
williamr@4
   736
	void AppendJustify(const TDesC16 &Des,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   737
	void AppendJustify(const TDesC16 &Des,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   738
	void AppendJustify(const TUint16 *aZeroTerminatedString,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   739
	void AppendJustify(const TUint16 *aZeroTerminatedString,TInt aLength,TInt aWidth,TAlign anAlignment,TChar aFill);
williamr@4
   740
	void AppendNumFixedWidthUC(TUint aVal,TRadix aRadix,TInt aWidth);
williamr@4
   741
	void AppendNumUC(TUint64 aVal, TRadix aRadix=EDecimal);
williamr@4
   742
	TInt AppendNum(TReal aVal,const TRealFormat &aFormat) __SOFTFP;
williamr@4
   743
	void AppendNum(TInt64 aVal);
williamr@4
   744
	void AppendNum(TUint64 aVal, TRadix aRadix);
williamr@4
   745
	void AppendFormat(TRefByValue<const TDesC16> aFmt,TDes16Overflow *aOverflowHandler,...);
williamr@4
   746
	void AppendFormat(TRefByValue<const TDesC16> aFmt,...);
williamr@4
   747
	void AppendFormatList(const TDesC16 &aFmt,VA_LIST aList,TDes16Overflow *aOverflowHandler=NULL);
williamr@4
   748
	// end of TDes16 methods
williamr@4
   749
	//---------------------------------------------------
williamr@4
   750
williamr@4
   751
	//----------------------------------------------------------
williamr@4
   752
	// These mutable RBuf16 methods have been privatised because
williamr@4
   753
	// they make assumptions which are incompatible with the 
williamr@4
   754
	// general use pattern of LString16.
williamr@4
   755
	void Swap(RBuf16& aRBuf);
williamr@4
   756
	TInt Create(TInt aMaxLength);
williamr@4
   757
	void CreateL(TInt aMaxLength);
williamr@4
   758
	TInt CreateMax(TInt aMaxLength);
williamr@4
   759
	void CreateMaxL(TInt aMaxLength);
williamr@4
   760
	TInt Create(const TDesC16& aDes);
williamr@4
   761
	void CreateL(const TDesC16& aDes);
williamr@4
   762
	TInt Create(const TDesC16& aDes,TInt aMaxLength);
williamr@4
   763
	void CreateL(const TDesC16& aDes,TInt aMaxLength);
williamr@4
   764
	void Close();
williamr@4
   765
	void CleanupClosePushL();
williamr@4
   766
	// end of privated RBuf16 methods
williamr@4
   767
	//---------------------------------------------------
williamr@4
   768
williamr@4
   769
	void EnsureCapacityIncrementL(TInt aLengthIncrement);
williamr@4
   770
	void IncreaseCapacityL();
williamr@4
   771
	
williamr@4
   772
private:
williamr@4
   773
	//reserved data member for future-proofing
williamr@4
   774
	TInt iReserved;
williamr@4
   775
	};
williamr@4
   776
williamr@4
   777
williamr@4
   778
/**
williamr@4
   779
Type alias for LString16.
williamr@4
   780
williamr@4
   781
LString is typically used in preference to LString16 when manipulating
williamr@4
   782
Unicode text, in the same way that TDesC is typically used in
williamr@4
   783
preference to TDesC16.
williamr@4
   784
*/
williamr@4
   785
typedef LString16 LString;
williamr@4
   786
williamr@4
   787
/**
williamr@4
   788
Type alias for LString8.
williamr@4
   789
williamr@4
   790
LData can be used to better express intent when using an LString8 to
williamr@4
   791
manipulate raw binary (non character) data.
williamr@4
   792
*/
williamr@4
   793
typedef LString8 LData;
williamr@4
   794
williamr@4
   795
#undef LSTRING_CONSTRUCTORS_MAY_LEAVE
williamr@4
   796
williamr@4
   797
#endif // !ESTRING_H