Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
laishikai edited this page Jul 5, 2019 · 1 revision

template class StringT

  • {
  •  // 功能:字符串与基础数据类型的连接
    
  •  // 参数:base_type - 基础数据类型
     public static StringT a + b + c + ... + n ; // 多个字符串连接 a, b 其中一必须是字符串类型,(c, ... n为任意基础数据类型)
     
     public void operator = (base_type other);
     public StringT operator += (base_type other);
     
     public StringT Clone(); // 克隆自己
     
     public _Ty operator[](int nIndex);
     public int GetLength(); // 
     pulbic int Length; // 取字符串的长度
     public char GetLastChar(); // 得到最后一个字符
     pulbic void SetAt(int nIndex, _Ty ch); // 设置字符
     public bool IsEmpty();
     public void Empty();
     public void Swap(StringT other);
     public void Preallocate(int nSize); // 预分配内存
     public void Reserve(nSize); // 预分配内存
     public void Format(StringT format, arg0, ...); // Format("{0},{1}", i, i); // 参考C#的String.Format
     public void AppendFormat(StringT format, arg0, ...); // Format("{0},{1}", i, i); // 参考C#的String.Format
     public void SetString(StringA str, int iStart, int nLen);
     public void SetString(StringW str, int iStart, int nLen);
     public void AppendChar( _Ty ch, int nCount);
     public void Append( StringT, int iStart, int nLen );
     public int ToInt();
     public int64 ToInt64();
     public float ToFloat();
     public double ToDouble();
     
     public StringT Left(int nCount);
     public StringT Right(int nCount);
     public StringT Mid(int iStart);
     public StringT Mid(int iStart, int nCount);
     public void TrimRight(); // 删除右侧的空格
     public void TrimLeft(); // 删除左侧的空格
     public void Trim(); // 删除两端的空格
     public StringT Tokenize( StringT szTokens, int& iStart ); // 分隔符查找
     public void Delete( int iIndex, int nCount);
     public void DelMiddle( int lowCh,int hightCh,int nBegin,int nEnd );
     public int Insert( int iIndex, _Ty ch, int nCount );
     public int Insert( int iIndex, _Ty ch );
     public int Insert( int iIndex, StringT psz );
     pulbic int Replace( _Ty chOld, _Ty chNew );
     public int Replace( StringT szOld, StringT szNew );
     public int Remove( _Ty chRemove );
     public void MakeUpper(); // 转换成大写
     public void MakeLower(); // 转换成小写
     public int Compare( StringT other ); // 比较字符串, 返回-1是小于,0是相等,1是大于
     public int CompareNoCase( StringT other ); // 比较字符串,忽略大小写
     // 使用通配符判断两个字符串是不是相似, bNoCase : true忽略大小写; false比较大小写
     public bool CompareWithWildcard( StringT szWildcard, bool bNoCase ); 
     public int Find( _Ty ch, int iStart ); // 从前向后查找指定的字符
     public int Find( StringT substr, int iStart);
     public int FindNoCase( StringT substr, int iStart );
     public int ReverseFind( _Ty ch ); // 从最后一个字符开始向前查找
     public int ReverseFind( _Ty ch, int nStart ); // 从nStart位置向前查找
     public void Inserve(); // 将字符串反序
     
     public bool operator == ( StringT other );
     public bool operator != ( StringT other );
     public bool operator > ( StringT other );
     public bool operator < ( StringT other );
     public bool operator >= ( StringT other );
     public bool operator <= ( StringT other );
    
    };

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /