⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wystr.h

📁 一个不错
💻 H
字号:
/* Copyright is licensed by GNU LGPL.                        (I.J. Wang, 2004)*/#ifndef WYSTR_H__#define WYSTR_H__#define WYSTR_VERSION 31#include "wyret.h"#include "wycseg.h"class Wy__HStr;/*  .No thread-cancellation points  Note: class allow direct manipulate of the array        (in valid range through member operator[] )*/class WyStr {  public:    typedef size_t size_type;    typedef char value_type;    // note: for test    //    #ifdef WY_DEBUG    typedef value_type* iterator;    typedef const value_type* const_iterator;    #endif    static const char class_name[];    WY_THROW_REPLY;    static size_type max_capacity(void) WY__TSPC();    static size_type min_capacity(void) WY__TSPC();    WyStr() WY__TSPC(Reply);    WyStr(const WyStr& str) WY__TSPC(Reply);    // Note: Instances of const char* is converted to WyCSeg    //    WyStr(const WyCSeg&) WY__TSPC(Reply);    WyStr(size_type num, value_type ch) WY__TSPC(Reply);    WyStr(WyStr& str, Wy::ByMove_t) WY__TSPC();    ~WyStr() WY__TSPC();    bool is_default(void) const WY__TSPC();    void reset(void) WY__TSPC();    WyRet reset(const WyStr& str) WY__TSPC();    WyRet reset(const WyCSeg& cs) WY__TSPC();    WyRet reset(size_type num,value_type ch) WY__TSPC();    size_type size(void) const WY__TSPC();    const value_type* begin(void) const WY__TSPC();    const value_type* end(void) const WY__TSPC();    const value_type& operator [](size_type pos) const WY__TSPC();    value_type& operator [](size_type pos) WY__TSPC();    const value_type& at(size_type pos) const WY__TSPC(Reply);    value_type& at(size_type pos) WY__TSPC(Reply);    const value_type* data(void) const WY__TSPC();    const value_type* c_str(void) const WY__TSPC();    const WyStr& operator =(const WyStr& rhs) WY__TSPC(Reply);    const WyStr& operator =(const WyCSeg& rhs) WY__TSPC(Reply);    void swap(WyStr& str) WY__TSPC();    WyRet append(value_type ch) WY__TSPC();    WyRet append(const WyStr& str) WY__TSPC();    WyRet append(const WyCSeg& cs) WY__TSPC();    WyRet append(size_type cnum,value_type ch) WY__TSPC();    const WyStr& operator +=(value_type ch) WY__TSPC(Reply);    const WyStr& operator +=(const WyStr& str) WY__TSPC(Reply);    const WyStr& operator +=(const WyCSeg& cs) WY__TSPC(Reply);    WyRet insert(size_type idx,const WyStr&) WY__TSPC();    WyRet insert(size_type idx,const WyCSeg&) WY__TSPC();    WyRet insert(size_type idx,size_type cnum,value_type ch) WY__TSPC();    WyRet erase(size_type idx) WY__TSPC();    WyRet erase(size_type idx,size_type len) WY__TSPC();    WyRet resize(size_type num) WY__TSPC();    WyRet resize(size_type num,value_type ch) WY__TSPC();    WyRet replace(size_type idx,size_type num,const WyStr& str) WY__TSPC();    WyRet replace(size_type idx,size_type num,const WyCSeg& cs) WY__TSPC();    WyRet replace(size_type idx,size_type num,size_type cnum,value_type ch) WY__TSPC();    WyRet copyto(size_type* rlen,value_type* buf,size_type blen,size_type idx) const WY__TSPC();    // [Evaluating]    // [Syn] Fill at most flen characters ch to the end of string of *this    //       The number of filled characters is flen-this->size(). If    //       If flen<str.size(), this member has no effect.    //           //  note: if this member is meaninful, because can reduce printf like    //        program a little bit    //    // [Throw] Reply    //         Wym_EFBIG    //         Wym_ENOMEM    //    WyStr& _fill_end(size_t flen, char ch) WY__TSPC(Reply);    // [Evaluating]    // [Syn] Fill the begining of the string with len-str.size() of character ch    //       if len<str.size(), no effect    //    // [Throw] Reply    //         Wym_EFBIG    //         Wym_ENOMEM    //    WyStr& _fill_begin(size_t wlen, char ch) WY__TSPC(Reply);    bool find(size_type* res,value_type ch) const WY__TSPC();    bool find(size_type* res,const WyCSeg& cs) const WY__TSPC();    bool find(size_type* res,size_type idx,value_type ch) const WY__TSPC();    bool find(size_type* res,size_type idx,const WyCSeg& cs) const WY__TSPC();    bool rfind(size_type* res,value_type ch) const WY__TSPC();    bool rfind(size_type* res,const WyCSeg& cs) const WY__TSPC();    bool rfind(size_type* res,size_type idx,value_type ch) const WY__TSPC();    bool rfind(size_type* res,size_type idx,const WyCSeg& cs) const WY__TSPC();    // [In Evaluation]    bool _find_in(size_type* res,size_type idx,const WyCSeg& cs) const WY__TSPC();    bool find_not(size_type* res,size_type idx,value_type ch) const WY__TSPC();    bool _find_not(size_type* res,size_type idx,const WyCSeg& cs) const WY__TSPC();    bool _rfind_in(size_type* res,size_type idx,const WyCSeg& cs) const WY__TSPC();    bool rfind_not(size_type* res,size_type idx,value_type ch) const WY__TSPC();    bool _rfind_not(size_type* res,size_type idx,const WyCSeg& cs) const WY__TSPC();    // Note: adding implicit conversion might be good    WyCSeg cseg(void) const WY__TSPC();    WyCSeg cseg(size_type idx) const WY__TSPC(Reply);    WyCSeg cseg(size_type idx, size_type num) const WY__TSPC(Reply);    bool operator ==(const WyStr& rhs) const WY__TSPC();    bool operator !=(const WyStr& rhs) const WY__TSPC();    bool operator ==(const WyCSeg& rhs) const WY__TSPC();    bool operator !=(const WyCSeg& rhs) const WY__TSPC();    bool operator ==(const char* rhs) const WY__TSPC(WyCSeg::Reply);    bool operator !=(const char* rhs) const WY__TSPC(WyCSeg::Reply);    // _strcmp    int _strcmp(const WyStr& str) const WY__TSPC();    int _strcmp(const WyCSeg& cs) const WY__TSPC();    int _strcmp(const char* cstr) const WY__TSPC(WyCSeg::Reply);    size_type _capacity(void) const WY__TSPC();    WyRet _reserve(size_type num) WY__TSPC();       WyRet _setsize(size_t nsize) WY__TSPC();  private:    // [Syn] Construct object to handle the given Wy__HStr object    //    //       data()= hstr->data()    //       size()= hstr->size()    //    WyStr(Wy__HStr* hstr) WY__TSPC();    Wy__HStr* _imp;    // Hidden    //WyStr(const char*);    WyStr(int);    WyStr(size_type num, int);    void reset(size_type num, int);    WyRet append(int);    WyRet append(size_type num, int);    const WyStr& operator +=(int);    class _Assertion;    friend WyStr operator +(const WyStr&,const WyStr&) WY__TSPC(WyStr::Reply);    friend WyStr operator +(const WyStr&,const WyCSeg&) WY__TSPC(WyStr::Reply);    friend WyStr operator +(const WyStr&,value_type) WY__TSPC(WyStr::Reply);    friend WyStr operator +(const WyCSeg&,const WyStr&) WY__TSPC(WyStr::Reply);    friend WyStr operator +(value_type ch,const WyStr& str) WY__TSPC(WyStr::Reply);};WyStr operator +(const WyStr& lhs,const WyStr& rhs) WY__TSPC(WyStr::Reply);WyStr operator +(const WyStr& str,const WyCSeg& cs) WY__TSPC(WyStr::Reply);WyStr operator +(const WyStr& str,WyStr::value_type ch) WY__TSPC(WyStr::Reply);WyStr operator +(const WyCSeg& cs,const WyStr& str) WY__TSPC(WyStr::Reply);WyStr operator +(WyStr::value_type ch,const WyStr& str) WY__TSPC(WyStr::Reply);inline bool operator ==(const WyCSeg& lhs, const WyStr& rhs) WY__TSPC()       { return rhs.operator==(lhs); };inline bool operator !=(const WyCSeg& lhs, const WyStr& rhs) WY__TSPC()       { return rhs.operator!=(lhs); };inline bool operator ==(const char* lhs, const WyStr& rhs) WY__TSPC(WyCSeg::Reply)       { return rhs.operator==(lhs); };inline bool operator !=(const char* lhs, const WyStr& rhs) WY__TSPC(WyCSeg::Reply)       { return rhs.operator!=(lhs); };namespace Wy { WyStr wrd(const WyReply& em) WY__TSPC(WyStr::Reply); WyStr wrd(const WyRet& em) WY__TSPC(WyStr::Reply); WyStr wrd(const Wy_SrcLoc& s) WY__TSPC(WyStr::Reply); inline int _strcmp(const WyStr& s1,const WyStr& s2) WY__TSPC()       { return s1.cseg()._strcmp(s2.cseg()); }; inline int _strcmp(const WyStr& str,const WyCSeg& cs) WY__TSPC()       { return str.cseg()._strcmp(cs); }; inline int _strcmp(const WyCSeg& cs,const WyStr& str) WY__TSPC()       { return cs._strcmp(str.cseg()); }; inline int _strcmp(const char* cstr, const WyStr& str) WY__TSPC(WyCSeg::Reply)       { return WyCSeg(cstr)._strcmp(str.cseg()); }; inline int _strcmp(const WyStr& str,const char* cstr) WY__TSPC(WyCSeg::Reply)       { return str.cseg()._strcmp(cstr); }; // [Syn] Convert the character in str to uppercase/lowercase // // [Ret] reference of argument str  WyStr& _toupper(WyStr& str) WY__TSPC(); WyStr& _tolower(WyStr& str) WY__TSPC();};  // End namespace Wy// For number conversion functions: Wy::_strnum(..) Wy::_sqrt(..),..// are declared in this header file, see wy.3wy//#include "wynum.h"// For number conversion functions: Wy::_mkstr(..), Wy::_catstr(..)//#include "wy__numstr.h"#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -