1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 inline String::String()
19 : iLength(0), iText(NULL)
23 inline String::String(const char* aText)
24 : iLength(0), iText(NULL)
26 if (aText && CreateText(strlen(aText)))
28 CopyText(iText, aText, iLength);
29 iText[iLength] = '\0';
33 inline String::String(int aLength,char* aText)
34 : iLength(0), iText(NULL)
36 if (aText && CreateText(aLength))
38 CopyText(iText, aText, aLength);
39 iText[iLength] = '\0';
43 inline String::String(const String& aString)
44 : iLength(0), iText(NULL)
46 if (CreateText(aString.iLength))
48 CopyText(iText, aString.iText, iLength);
49 iText[iLength] = '\0';
53 inline String& String::operator = (const char* aText)
56 if (CreateText(strlen(aText)))
58 CopyText(iText, aText, iLength);
59 iText[iLength] = '\0';
65 inline String& String::operator = (const String& aString)
67 String string(aString);
69 if (CreateText(string.iLength))
71 CopyText(iText, string.iText, iLength);
72 iText[iLength] = '\0';
78 inline String& String::operator += (const char aChar)
81 if (CreateText(iLength + 1))
83 CopyText(iText, text, iLength - 1);
84 iText[iLength - 1] = aChar;
85 iText[iLength] = '\0';
91 inline String& String::operator += (const String& aString)
95 if (CreateText(length + aString.iLength))
97 CopyText(iText, text, length);
98 CopyText(iText + length, aString.iText, aString.iLength);
99 iText[iLength] = '\0';
105 inline int String::operator == (const String& aString) const
107 boolean same = etrue;
108 if (iLength != aString.iLength)
112 for (int i = 0; i < iLength; i++)
113 same = same && ((*this)[i] == aString[i]);
118 inline char& String::operator [] (const int aNum) const
123 inline int String::Length() const
128 inline const char* String::Text()
133 inline void String::CopyText(char* aDest, const char* aSource, int aLength) const
135 for (int i = 0; i < aLength; i++)
136 aDest[i] = aSource[i];