inline string &operator++(string &str)
{
char szBuf[32];
int num=atoi(str.c_str());
str = itoa(szBuf, ++num, 10);
return str;
}
inline string &operator--(string &str)
{
char szBuf[32];
int num=atoi(str.c_str());
str = itoa(szBuf, --num, 10);
return str;
}
inline string operator+(string const &str)
{
string ret(str);
return ++ret;
}
inline string &operator-(string &str)
{
for (int i=0; i<str.size(); ++i)
{
str[i] = tolower(str[i]); // 非大写字母不转换
}
return str;
}
inline string operator-(string const &str)
{
string ret(str);
return --ret;
}
inline bool operator<<=(string const &sBuf, string const &sPre) // 前缀比较
{
return sBuf.compare(0, sPre.size(), sPre) == 0;
}
inline bool operator>>=(string const &sBuf, string const &sSuf) // 后缀比较
{
if (sBuf.size() < sSuf.size()) return false;
return sBuf.compare(sBuf.size()-sSuf.size(), sSuf.size(), sSuf) == 0;
}
static char const *const g_Mark=" .,;()/r/n"; // 其它字符被当作标识符的组成部分处理
inline string::size_type operator%(string const &str, string::size_type index) // 返回直接后趋单词的偏移值
{
index = str.find_first_of(g_Mark, index); // 注意连续分隔符被归并处理,当作一个分隔符解释
if (index == string::npos) return index;
index = str.find_first_not_of(g_Mark, index);
return index;
}
inline string operator->*(string const &str, string::size_type index) // 返回与指定偏移最近当前单词之克隆体
{
index = str.find_first_not_of(g_Mark, index);
if (index == string::npos) return "";
string::size_type ender=str.find_first_of(g_Mark, index);
if (ender == string::npos) ender = str.size();
return str.substr(index, ender-index);
}