TCDynStr::TCDynStr(const TCString& str,uint pos,uint count) /**************************************************************************** * * Function: TCDynStr::TCDynStr * Parameters: str - TCString to copy from * pos - Starting position in the string * count - Number of characters to copy * * Description: Constructs a string from another string, starting at the * position 'pos' and including 'count' characters. * ****************************************************************************/ { CHECK(str.valid()); if (pos > str.length()) pos = str.length(); if (count > str.length() - pos) count = str.length() - pos; len = count+1; size = computeSize(len); if ((text = new char[size]) != NULL) { memcpy(text,(const char *)str+pos,len); text[count] = '\0'; // Null terminate the string } }
TCSubStr::TCSubStr(const TCString& str,uint pos,uint count) /**************************************************************************** * * Function: TCSubStr::TCSubStr * Parameters: str - TCString to copy from * pos - Starting position in the string * count - Number of characters to copy * * Description: Constructs a TCSubStr from another string, starting at the * position 'pos' and including 'count' characters. * ****************************************************************************/ { CHECK(str.valid()); if (pos > str.length()) pos = str.length(); if (count > str.length() - pos) count = str.length() - pos; len = count+1; text = (char *)((const char *)str + pos); }
TCDynStr operator * (const TCString& s1,uint count) { CHECK(s1.valid()); TCDynStr s(s1); return s *= count; }
TCDynStr operator + (const char *s1,const TCString& s2) { CHECK(s1 != NULL && s2.valid()); TCDynStr s(s1); return s += s2; }
TCDynStr operator + (const TCString& s1,const TCString& s2) { CHECK(s1.valid() && s2.valid()); TCDynStr s(s1); return s += s2; }