graphicstools/bitmapfonttools/inc/STRNG.INL
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 /*
       
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * Header STRNG.INL
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @publishedAll 
       
    23 */
       
    24 
       
    25 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
    26 inline String::String()
       
    27  :	iLength(0), iText(NULL)
       
    28 	{
       
    29 	}
       
    30 
       
    31 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
    32 inline String::String(const char* aText)
       
    33  :	iLength(0), iText(NULL)
       
    34 	{
       
    35 	if (aText && CreateText(strlen(aText)))
       
    36 		{
       
    37 		CopyText(iText, aText, iLength);
       
    38 		iText[iLength] = '\0';
       
    39 		}
       
    40 	}
       
    41 
       
    42 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
    43 inline String::String(int aLength,char* aText)
       
    44  :	iLength(0), iText(NULL)
       
    45 	{
       
    46 	if (aText && CreateText(aLength))
       
    47 		{
       
    48 		CopyText(iText, aText, aLength);
       
    49 		iText[iLength] = '\0';
       
    50 		}
       
    51 	}
       
    52 
       
    53 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
    54 inline String::String(const String& aString)
       
    55  :	iLength(0), iText(NULL)
       
    56 	{
       
    57 	if (CreateText(aString.iLength))
       
    58 		{
       
    59 		CopyText(iText, aString.iText, iLength);
       
    60 		iText[iLength] = '\0';
       
    61 		}
       
    62 	}
       
    63 
       
    64 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
    65 inline String& String::operator = (const char* aText)
       
    66 	{
       
    67 	char* text = iText;
       
    68 	if (CreateText(strlen(aText)))
       
    69 		{
       
    70 		CopyText(iText, aText, iLength);
       
    71 		iText[iLength] = '\0';
       
    72 		DeleteText(text);
       
    73 		}
       
    74 	return *this;
       
    75 	}
       
    76 
       
    77 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
    78 inline String& String::operator = (const String& aString)
       
    79 	{
       
    80 	String string(aString);
       
    81 	char* text = iText;
       
    82 	if (CreateText(string.iLength))
       
    83 		{
       
    84 		CopyText(iText, string.iText, iLength);
       
    85 		iText[iLength] = '\0';
       
    86 		DeleteText(text);
       
    87 		}
       
    88 	return *this;
       
    89 	}
       
    90 
       
    91 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
    92 inline String& String::operator += (const char aChar)
       
    93 	{
       
    94 	char* text = iText;
       
    95 	if (CreateText(iLength + 1))
       
    96 		{
       
    97 		CopyText(iText, text, iLength - 1);
       
    98 		iText[iLength - 1] = aChar;
       
    99 		iText[iLength] = '\0';
       
   100 		DeleteText(text);
       
   101 		}
       
   102 	return *this;
       
   103 	}
       
   104 
       
   105 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
   106 inline String& String::operator += (const String& aString)
       
   107 	{
       
   108 	char* text = iText;
       
   109 	int length = iLength;
       
   110 	if (CreateText(length + aString.iLength))
       
   111 		{
       
   112 		CopyText(iText, text, length);
       
   113 		CopyText(iText + length, aString.iText, aString.iLength);
       
   114 		iText[iLength] = '\0';
       
   115 		DeleteText(text);
       
   116 		}
       
   117 	return *this;
       
   118 	}
       
   119 
       
   120 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
   121 inline int String::operator == (const String& aString) const
       
   122 	{
       
   123 	boolean same = etrue;
       
   124 	if (iLength != aString.iLength)
       
   125 		same = efalse;
       
   126 	else
       
   127 		{
       
   128 		for (int i = 0; i < iLength; i++)
       
   129 			same = same && ((*this)[i] == aString[i]);
       
   130 		}
       
   131 	return same;
       
   132 	}
       
   133 
       
   134 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
   135 inline char& String::operator [] (const int aNum) const
       
   136 	{
       
   137 	return iText[aNum];
       
   138 	}
       
   139 
       
   140 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
   141 inline int String::Length() const
       
   142 	{
       
   143 	return iLength;
       
   144 	}
       
   145 
       
   146 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
   147 inline const char* String::Text()
       
   148 	{
       
   149 	return iText;
       
   150 	}
       
   151 
       
   152 /** WARNING:  Functon for internal use ONLY.  Compatibility is not guaranteed in future releases. */
       
   153 inline void String::CopyText(char* aDest, const char* aSource, int aLength) const
       
   154 	{
       
   155 	for (int i = 0; i < aLength; i++)
       
   156 		aDest[i] = aSource[i];
       
   157 	}