📄 superstr.h
字号:
Finder () : Find() { }
Finder (Finder const & f) : Find() { } // intercept generated constructor
};
// all these should have a clone() and/or a copy constructor and destructor if needed
struct FindChar : public Finder {
char _c;
FindChar (char c);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindCharNoCase : public FindChar {
FindCharNoCase (char c);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindFunc : public Finder {
typedef bool(*Func)(char c);
Func _f;
FindFunc (Func f);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindSet : public Finder {
SSCopyPointer _set;
FindSet (SS const & charset);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindString : public Finder {
SSCopyPointer _str;
FindString (SS const & str);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindVector : public Finder {
typedef Find const & F;
std::vector<Find const *>* _rep;
FindVector (int n=0);
FindVector (FindVector const & fv);
void add (F f);
virtual int size () const;
virtual Find const & operator [] (int i) const;
Finder* clone () const;
~FindVector ();
};
struct FindSequence : public FindVector {
FindSequence ();
FindSequence (F f0, F f1);
FindSequence (F f0, F f1, F f2);
FindSequence (F f0, F f1, F f2, F f3);
FindSequence (F f0, F f1, F f2, F f3, F f4);
FindSequence (F f0, F f1, F f2, F f3, F f4, F f5);
FindSequence (F f0, F f1, F f2, F f3, F f4, F f5, F f6);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindStringNoCase : public FindSequence {
FindStringNoCase (SS const & s);
};
struct FindProxy : public Finder {
Find const * _f;
FindProxy (Find const & f);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
~FindProxy ();
protected: FindProxy (FindProxy const & f);
};
struct FindNot : public FindProxy {
FindNot (Find const & f);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
protected: FindNot (FindNot const & f);
};
struct FindOr : public FindVector {
FindOr ();
FindOr (F f0, F f1);
FindOr (F f0, F f1, F f2);
FindOr (F f0, F f1, F f2, F f3);
FindOr (F f0, F f1, F f2, F f3, F f4);
FindOr (F f0, F f1, F f2, F f3, F f4, F f5);
FindOr (F f0, F f1, F f2, F f3, F f4, F f5, F f6);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindAnd : public FindVector {
FindAnd ();
FindAnd (F f0, F f1);
FindAnd (F f0, F f1, F f2);
FindAnd (F f0, F f1, F f2, F f3);
FindAnd (F f0, F f1, F f2, F f3, F f4);
FindAnd (F f0, F f1, F f2, F f3, F f4, F f5);
FindAnd (F f0, F f1, F f2, F f3, F f4, F f5, F f6);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindCharCompare : public FindChar {
typedef bool(*Comp)(char u, char w);
Comp _comp;
FindCharCompare (char w, Comp comp);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindCharGreaterThan : public FindCharCompare {
FindCharGreaterThan (char w);
};
struct FindCharGreaterThanEqual : public FindCharCompare {
FindCharGreaterThanEqual (char w);
};
struct FindCharLessThan : public FindCharCompare {
FindCharLessThan (char w);
};
struct FindCharLessThanEqual : public FindCharCompare {
FindCharLessThanEqual (char w);
};
struct FindCharInRange : public FindAnd {
FindCharInRange (char w_low, char w_high);
};
struct FindCompare : public FindProxy {
typedef bool(*Comp)(SS const & u, SS const & w);
SSCopyPointer _w;
Comp _comp;
FindCompare (Find const & f, SS const & w, Comp comp);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindGreaterThan : public FindCompare {
FindGreaterThan (Find const & f, SS const & w);
};
struct FindGreaterThanEqual : public FindCompare {
FindGreaterThanEqual (Find const & f, SS const & w);
};
struct FindLessThan : public FindCompare {
FindLessThan (Find const & f, SS const & w);
};
struct FindLessThanEqual : public FindCompare {
FindLessThanEqual (Find const & f, SS const & w);
};
struct FindInRange : public FindAnd {
FindInRange (Find const & f, SS const & w_low, SS const & w_high);
};
struct FindBool : public Finder {
bool _b;
int _l;
FindBool (bool b, int l=0);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindPosition : public Finder {
int _n;
FindPosition (int n);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindRange : public Finder {
int _n, _l;
FindRange (int n, int l);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindDisplacedBy : public FindProxy {
int _n;
FindDisplacedBy (Find const & f, int n);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindMultiple : public FindProxy {
int _n,_m;
FindMultiple (Find const & f, int n=1);
FindMultiple (Find const & f, int n_min, int n_max);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
protected: FindMultiple (FindMultiple const & f);
};
struct FindZeroOrMore : public FindMultiple {
FindZeroOrMore (Find const & f);
};
struct FindOneOrMore : public FindMultiple {
FindOneOrMore (Find const & f);
};
struct FindZeroOrOne : public FindMultiple {
FindZeroOrOne (Find const & f);
};
struct FindAtLeast : public FindMultiple {
FindAtLeast (Find const & f, int n);
};
struct FindUpTo : public FindMultiple {
FindUpTo (Find const & f, int n);
};
struct FindAfter : public FindVector {
FindAfter (F f0, F f1);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindWithin : public FindAfter {
FindWithin (F f0, F f1);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindSeparatedBy : public FindAfter {
int _n;
FindSeparatedBy (F f0, F f1, int n);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindCloserThan : public FindSeparatedBy {
FindCloserThan (F f0, F f1, int n);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindFartherThan : public FindSeparatedBy {
FindFartherThan (F f0, F f1, int n);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
struct FindDelimit : public Finder {
char _c0,_c1;
FindDelimit (char c);
FindDelimit (char left, char right);
bool found (SS const & s, int pos, int& len) const;
Finder* clone () const;
};
// a few predefined objects for the finding members
static const FindFunc whitespace;
static const FindFunc blackspace;
static const FindFunc lowercase;
static const FindFunc uppercase;
static const FindFunc alpha;
static const FindFunc digit;
static const FindFunc alphanumeric;
static const FindFunc punct;
static const FindFunc printable;
static const FindFunc hexdigit;
static const FindFunc cntrl;
static const FindFunc graph;
static const FindBool findtrue;
static const FindBool findfalse;
static const FindBool anychar;
static const FindPosition frontposition;
static const FindPosition backposition;
static const FindOr endofline; // the position of the char before eol char(s)
static const FindDelimit singlequotedelimit;
static const FindDelimit doublequotedelimit;
static const FindDelimit parendelimit;
// a region or ref is simply a char* to an internal part of the parent string
// it will not in general be null-terminated
// it will be invalid when the (ultimate) parent goes out of scope
// if a ref is copied, the new string will also be a ref
SS getRegion (int beg=0, int len=fullength) const;
SS getRegion (Pair<int> const & beglen) const;
std::vector<SS>& getRegion (std::vector<SS>& s, std::vector< Pair<int> > const & beglen) const;
// stl iterators
char * begin ();
char const * begin () const;
char * end ();
char const * end () const;
// copying
template <class T>
SS& operator = (T const & t) { SSconvert (t,*this); return *this; }
SS& operator = (SS const & s) { assign (s); return *this; }
// member concatenation
template <class T>
SS operator + (T const & t) const { return concatenate (*this,t); }
template <class T>
SS& operator += (T const & t) { assign (concatenate (*this, t)); return *this; }
// member relational operators
template <class T>
bool operator == (T const & t) const { return SScompare (*this, t) == 0; }
template <class T>
bool operator != (T const & t) const { return SScompare (*this, t) != 0; }
template <class T>
bool operator < (T const & t) const { return SScompare (*this, t) < 0; }
template <class T>
bool operator > (T const & t) const { return SScompare (*this, t) > 0; }
template <class T>
bool operator <= (T const & t) const { return SScompare (*this, t) <= 0; }
template <class T>
bool operator >= (T const & t) const { return SScompare (*this, t) >= 0; }
// resolve some ambiguity
SS operator + (SS s);
SS operator + (SS s) const;
bool operator == (SS s);
bool operator == (SS s) const;
bool operator != (SS s);
bool operator != (SS s) const;
bool operator < (SS s);
bool operator < (SS s) const;
bool operator > (SS s);
bool operator > (SS s) const;
bool operator <= (SS s);
bool operator <= (SS s) const;
bool operator >= (SS s);
bool operator >= (SS s) const;
// these construct char representations of the numbers
// this is what is means to convert a number to a string
void assign (SS const & s);
void assign (string const & s);
void assign (char const * s);
void assign (unsigned char const * s);
void assign (signed char const * s);
void assign (char v);
void assign (unsigned char v);
void assign (signed char v);
void assign (bool v);
void assign (short v);
void assign (unsigned short v);
void assign (int v);
void assign (unsigned int v);
void assign (long v);
void assign (unsigned long v);
void assign (LongLong v);
void assign (ULongLong v);
void assign (float v);
void assign (double v);
void assign (long double v);
void assign (std::vector<char> const & v);
void assign (Buffer const & v);
void assign (void const * v, int n);
int compare (SS const & s) const;
int compare (string const & s) const;
int compare (char const * s) const;
int compare (unsigned char const * s) const;
int compare (signed char const * s) const;
int compare (char v) const;
int compare (unsigned char v) const;
int compare (signed char v) const;
int compare (bool v) const;
int compare (short v) const;
int compare (unsigned short v) const;
int compare (int v) const;
int compare (unsigned int v) const;
int compare (long v) const;
int compare (unsigned long v) const;
int compare (LongLong v) const;
int compare (ULongLong v) const;
int compare (float v) const;
int compare (double v) const;
int compare (long double v) const;
int compare (std::vector<char> const & s) const;
int compareNoCase (SS const & s) const;
int compare (void const * v, int n) const;
bool compare (Find const & f) const; // does f match the whole string?
bool isUpperCase (int pos) const;
bool isLowerCase (int pos) const;
bool isWhiteSpace (int pos) const;
bool isBlackSpace (int pos) const;
bool isAlpha (int pos) const;
bool isDigit (int pos) const;
bool isAlphaNumeric (int pos) const;
bool isPunct (int pos) const;
bool isPrintable (int pos) const;
bool isHexDigit (int pos) const;
bool isCntrl (int pos) const;
bool isGraph (int pos) const;
SS& toLower ();
SS& toLower (int pos);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -