📄 ysstring.h
字号:
#if !defined(__YS_STRING_H__)#define __YS_STRING_H__/** * * 文 件 名 : YsString.h * 创建日期 : 2006-09-27 * 作 者 : 邵凯田(skt001@163.com) * 修改日期 : $Date: 2006/10/19 02:06:41 $ * 当前版本 : $Revision: 1.2 $ * 功能描述 : a string class just like QString * 修改记录 : * $Log: YsString.h,v $ * Revision 1.2 2006/10/19 02:06:41 tester * 修改communicate,xml,ini * **/#include <stdio.h>#include <stdlib.h>#include <string>#include <stdarg.h>#include "YsList.h"class YsString;typedef YsString QString;typedef YsString QCString;typedef YsString CString;//#define YsStringList YsStringList<YsString>//#define QStringList YsStringList<YsString>typedef CYsClassList<QString> YsStringList;typedef YsStringList QStringList;class YsString {public: YsString(); YsString(const char *pStr); YsString(char *pStr); YsString(const YsString &str); virtual ~YsString(); bool isEmpty() const; char* data() const; char at(int index) const; YsString substr(int beg,int len=0); int length() const; int size() {return length();}; int count() {return size();}; YsString arg(int a, int fieldWidth = 0, int base = 10, char fillChar=' '); //The fieldWidth value specifies the minimum amount of space that a is padded to and filled with //the character fillChar. A positive value will produce a right-aligned number, //whereas a negative value will produce a left-aligned number. void clear(); int compare(const YsString &str);//比较 int compareNoCase(const YsString &str);//大小写不敏感比较 int find(char c, int i = 0, bool cs = true);//查找字符,cs是否大小写敏感 int find(YsString s, int i = 0, bool cs = true);//查找字符串,cs是否大小写敏感 int findRev(char c, int i = -1, bool cs = true);//反向查找字符,cs是否大小写敏感 int findRev(YsString s, int i = -1, bool cs = true);//反向查找字符串,cs是否大小写敏感 YsString &operator=(char c); YsString &operator=(char* s) { YsString str(s); *this = str; return *this; } operator const char * () const { return data(); } char operator[](int index) const { return at(index); } YsString &operator=(const YsString &s); bool operator==(const YsString &s); bool operator==(const char *s); bool operator!=(const YsString &s); bool operator!=(const char *s); YsString operator+(const YsString &s); YsString operator+(char c); YsString operator+(char *s) ; //YsString operator+(char *s, const YsString &s2) ; YsString & operator+=( char c ); YsString & operator+=( const char * str ); YsString & operator+=( char *str ); YsString & operator+=( const YsString & other ); YsString left(int len); YsString right(int len); YsString mid(int i, int len = -1); YsString replace ( int pos, int len, const YsString & s ); YsString replace ( int pos, int len, const char * str); YsString replace ( int pos, int len, char c ); YsString replace ( const YsString &before, const YsString &after, bool cs=true);//cs: case sensitive YsString& sprintf(const char * cformat, ...); YsString toUpper(); YsString toLower(); short toShort(bool * ok=0); int toInt(bool * ok=0); long toLong(bool * ok=0); unsigned short toUShort(bool * ok=0); unsigned int toUInt(bool * ok=0); unsigned long toULong(bool * ok=0); float toFloat(bool *ok=0); double toDouble(bool *ok=0); YsString upper(); YsString lower(); YsString stripWhiteSpace(); YsString fill(char ch, int size=-1); std::string m_str;};inline const YsString operator+(const YsString &s1, const YsString &s2){ YsString s=s1; s+=s2; return s;};#endif // !defined(__YS_STRING_H__)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -