sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * Header STRNG.INL sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @publishedAll sl@0: */ sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline String::String() sl@0: : iLength(0), iText(NULL) sl@0: { sl@0: } sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline String::String(const char* aText) sl@0: : iLength(0), iText(NULL) sl@0: { sl@0: if (aText && CreateText(strlen(aText))) sl@0: { sl@0: CopyText(iText, aText, iLength); sl@0: iText[iLength] = '\0'; sl@0: } sl@0: } sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline String::String(int aLength,char* aText) sl@0: : iLength(0), iText(NULL) sl@0: { sl@0: if (aText && CreateText(aLength)) sl@0: { sl@0: CopyText(iText, aText, aLength); sl@0: iText[iLength] = '\0'; sl@0: } sl@0: } sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline String::String(const String& aString) sl@0: : iLength(0), iText(NULL) sl@0: { sl@0: if (CreateText(aString.iLength)) sl@0: { sl@0: CopyText(iText, aString.iText, iLength); sl@0: iText[iLength] = '\0'; sl@0: } sl@0: } sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline String& String::operator = (const char* aText) sl@0: { sl@0: char* text = iText; sl@0: if (CreateText(strlen(aText))) sl@0: { sl@0: CopyText(iText, aText, iLength); sl@0: iText[iLength] = '\0'; sl@0: DeleteText(text); sl@0: } sl@0: return *this; sl@0: } sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline String& String::operator = (const String& aString) sl@0: { sl@0: String string(aString); sl@0: char* text = iText; sl@0: if (CreateText(string.iLength)) sl@0: { sl@0: CopyText(iText, string.iText, iLength); sl@0: iText[iLength] = '\0'; sl@0: DeleteText(text); sl@0: } sl@0: return *this; sl@0: } sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline String& String::operator += (const char aChar) sl@0: { sl@0: char* text = iText; sl@0: if (CreateText(iLength + 1)) sl@0: { sl@0: CopyText(iText, text, iLength - 1); sl@0: iText[iLength - 1] = aChar; sl@0: iText[iLength] = '\0'; sl@0: DeleteText(text); sl@0: } sl@0: return *this; sl@0: } sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline String& String::operator += (const String& aString) sl@0: { sl@0: char* text = iText; sl@0: int length = iLength; sl@0: if (CreateText(length + aString.iLength)) sl@0: { sl@0: CopyText(iText, text, length); sl@0: CopyText(iText + length, aString.iText, aString.iLength); sl@0: iText[iLength] = '\0'; sl@0: DeleteText(text); sl@0: } sl@0: return *this; sl@0: } sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline int String::operator == (const String& aString) const sl@0: { sl@0: boolean same = etrue; sl@0: if (iLength != aString.iLength) sl@0: same = efalse; sl@0: else sl@0: { sl@0: for (int i = 0; i < iLength; i++) sl@0: same = same && ((*this)[i] == aString[i]); sl@0: } sl@0: return same; sl@0: } sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline char& String::operator [] (const int aNum) const sl@0: { sl@0: return iText[aNum]; sl@0: } sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline int String::Length() const sl@0: { sl@0: return iLength; sl@0: } sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline const char* String::Text() sl@0: { sl@0: return iText; sl@0: } sl@0: sl@0: /** WARNING: Functon for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: inline void String::CopyText(char* aDest, const char* aSource, int aLength) const sl@0: { sl@0: for (int i = 0; i < aLength; i++) sl@0: aDest[i] = aSource[i]; sl@0: }