1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/STRNG.INL Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,137 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// 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
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Header STRNG.INL
1.18 +//
1.19 +//
1.20 +
1.21 +inline String::String()
1.22 + : iLength(0), iText(NULL)
1.23 + {
1.24 + }
1.25 +
1.26 +inline String::String(const char* aText)
1.27 + : iLength(0), iText(NULL)
1.28 + {
1.29 + if (aText && CreateText(strlen(aText)))
1.30 + {
1.31 + CopyText(iText, aText, iLength);
1.32 + iText[iLength] = '\0';
1.33 + }
1.34 + }
1.35 +
1.36 +inline String::String(int aLength,char* aText)
1.37 + : iLength(0), iText(NULL)
1.38 + {
1.39 + if (aText && CreateText(aLength))
1.40 + {
1.41 + CopyText(iText, aText, aLength);
1.42 + iText[iLength] = '\0';
1.43 + }
1.44 + }
1.45 +
1.46 +inline String::String(const String& aString)
1.47 + : iLength(0), iText(NULL)
1.48 + {
1.49 + if (CreateText(aString.iLength))
1.50 + {
1.51 + CopyText(iText, aString.iText, iLength);
1.52 + iText[iLength] = '\0';
1.53 + }
1.54 + }
1.55 +
1.56 +inline String& String::operator = (const char* aText)
1.57 + {
1.58 + char* text = iText;
1.59 + if (CreateText(strlen(aText)))
1.60 + {
1.61 + CopyText(iText, aText, iLength);
1.62 + iText[iLength] = '\0';
1.63 + DeleteText(text);
1.64 + }
1.65 + return *this;
1.66 + }
1.67 +
1.68 +inline String& String::operator = (const String& aString)
1.69 + {
1.70 + String string(aString);
1.71 + char* text = iText;
1.72 + if (CreateText(string.iLength))
1.73 + {
1.74 + CopyText(iText, string.iText, iLength);
1.75 + iText[iLength] = '\0';
1.76 + DeleteText(text);
1.77 + }
1.78 + return *this;
1.79 + }
1.80 +
1.81 +inline String& String::operator += (const char aChar)
1.82 + {
1.83 + char* text = iText;
1.84 + if (CreateText(iLength + 1))
1.85 + {
1.86 + CopyText(iText, text, iLength - 1);
1.87 + iText[iLength - 1] = aChar;
1.88 + iText[iLength] = '\0';
1.89 + DeleteText(text);
1.90 + }
1.91 + return *this;
1.92 + }
1.93 +
1.94 +inline String& String::operator += (const String& aString)
1.95 + {
1.96 + char* text = iText;
1.97 + int length = iLength;
1.98 + if (CreateText(length + aString.iLength))
1.99 + {
1.100 + CopyText(iText, text, length);
1.101 + CopyText(iText + length, aString.iText, aString.iLength);
1.102 + iText[iLength] = '\0';
1.103 + DeleteText(text);
1.104 + }
1.105 + return *this;
1.106 + }
1.107 +
1.108 +inline int String::operator == (const String& aString) const
1.109 + {
1.110 + boolean same = etrue;
1.111 + if (iLength != aString.iLength)
1.112 + same = efalse;
1.113 + else
1.114 + {
1.115 + for (int i = 0; i < iLength; i++)
1.116 + same = same && ((*this)[i] == aString[i]);
1.117 + }
1.118 + return same;
1.119 + }
1.120 +
1.121 +inline char& String::operator [] (const int aNum) const
1.122 + {
1.123 + return iText[aNum];
1.124 + }
1.125 +
1.126 +inline int String::Length() const
1.127 + {
1.128 + return iLength;
1.129 + }
1.130 +
1.131 +inline const char* String::Text()
1.132 + {
1.133 + return iText;
1.134 + }
1.135 +
1.136 +inline void String::CopyText(char* aDest, const char* aSource, int aLength) const
1.137 + {
1.138 + for (int i = 0; i < aLength; i++)
1.139 + aDest[i] = aSource[i];
1.140 + }