newconveniencefunctions1
This commit is contained in:
@ -38,6 +38,9 @@ static const ams_chartype ams_char_cr = (ams_chartype) '\r'; //carriage return
|
||||
static const ams_chartype ams_char_lf = (ams_chartype) '\n'; //newline
|
||||
static const ams_chartype ams_char_tb = (ams_chartype) '\t'; //tab
|
||||
static const ams_chartype ams_char_nt = (ams_chartype) '\0'; //null terminator
|
||||
static const ams_chartype ams_char_dq = (ams_chartype) '"'; //doublequote
|
||||
static const ams_chartype ams_char_sq = (ams_chartype) '\''; //singlequote
|
||||
|
||||
|
||||
class amsstring
|
||||
{
|
||||
@ -120,24 +123,26 @@ public:
|
||||
|
||||
bool isvalidnumber();
|
||||
double strtonum();
|
||||
|
||||
//updated convenience functions as class members
|
||||
};
|
||||
|
||||
//needs work
|
||||
void splitlines(amsstring *s, std::vector<amsstring> *lns);
|
||||
void splitlines(amsstring *s, ams::amsarray<amsstring> *lns);
|
||||
//void splitlines(const amsstring *s, std::vector<amsstring> *lns);
|
||||
void splitlines(const amsstring *s, ams::amsarray<amsstring> *lns);
|
||||
|
||||
void split(amsstring *s, const ams_chartype delimitchar, std::vector<amsstring> *lns);
|
||||
void split(amsstring *s, const ams_chartype delimitchar, ams::amsarray<amsstring> *lns);
|
||||
//void split(const amsstring *s, const ams_chartype delimitchar, std::vector<amsstring> *lns);
|
||||
void split(const amsstring *s, const ams_chartype delimitchar, ams::amsarray<amsstring> *lns);
|
||||
|
||||
void split(amsstring *s, const ams_chartype *delimitstr, std::vector<amsstring> *lns);
|
||||
void split(amsstring *s, const ams_chartype *delimitstr, ams::amsarray<amsstring> *lns);
|
||||
//void split(const amsstring *s, const ams_chartype *delimitstr, std::vector<amsstring> *lns);
|
||||
void split(const amsstring *s, const ams_chartype *delimitstr, ams::amsarray<amsstring> *lns);
|
||||
|
||||
void split(amsstring *s, amsstring *delimitstr, std::vector<amsstring> *lns);
|
||||
void split(amsstring *s, amsstring *delimitstr, ams::amsarray<amsstring> *lns);
|
||||
//void split(const amsstring *s, amsstring *delimitstr, std::vector<amsstring> *lns);
|
||||
void split(const amsstring *s, amsstring *delimitstr, ams::amsarray<amsstring> *lns);
|
||||
|
||||
//splits a string, not counting whitespaces between non-whitespace characters
|
||||
void splitwhitespace(amsstring *s, std::vector<amsstring> *lns);
|
||||
void splitwhitespace(amsstring *s, ams::amsarray<amsstring> *lns);
|
||||
//void splitwhitespace(const amsstring *s, std::vector<amsstring> *lns);
|
||||
void splitwhitespace(const amsstring *s, ams::amsarray<amsstring> *lns);
|
||||
|
||||
//removes all whitespace characters '\t','\r','\n' included
|
||||
//to the left and right of the string (but not in the middle)
|
||||
@ -146,6 +151,37 @@ void stripwhitespace(amsstring *s);
|
||||
//completely removes all whitespace entirely
|
||||
void stripallwhitespace(amsstring *s);
|
||||
|
||||
|
||||
//Updated convenience functions: updated for a more python style
|
||||
amsarray<amsstring> splitlines(const amsstring &s);
|
||||
amsarray<amsstring> split(const amsstring &s, const ams_chartype delimitchar);
|
||||
amsarray<amsstring> split(const amsstring &s, const ams_chartype *delimitstr);
|
||||
|
||||
//splits into two guaranteed pieces
|
||||
//if a delimitchar or delimitstr is not encountered, the first piece will contain the entire string and the second will be ""
|
||||
amsarray<amsstring> splitfirst(const amsstring &s, const ams_chartype delimitchar);
|
||||
amsarray<amsstring> splitfirst(const amsstring &s, const ams_chartype *delimitstr);
|
||||
|
||||
//splits a string, not counting whitespaces between non-whitespace characters
|
||||
amsarray<amsstring> splitwhitespace(const amsstring &s);
|
||||
amsstring stripwhitespace(const amsstring &s);
|
||||
amsstring stripallwhitespace(const amsstring &s);
|
||||
|
||||
//splits into two guaranteed pieces
|
||||
//if an extension separator . is not encountered, the first piece will contain the entire string, the second ""
|
||||
amsarray<amsstring> splitext(const amsstring &s);
|
||||
|
||||
//splits into two guaranteed pieces
|
||||
//if a path separator is not encountered, the second piece will contain the entire string, and the first ""
|
||||
amsarray<amsstring> splitpath(const amsstring &s);
|
||||
|
||||
//selects between the outermost set of delimitleft and delimitright chars
|
||||
amsstring select_between(const amsstring &s, const ams_chartype delimitleft, const ams_chartype delimitright);
|
||||
|
||||
amsstring concatenate(const amsarray<amsstring> &slist);
|
||||
|
||||
|
||||
|
||||
void freadline(FILE *fp, amsstring *s);
|
||||
void freadlines(FILE *fp, std::vector<amsstring> *lines);
|
||||
void fwritelines(FILE *fp, amsstring *s);
|
||||
|
||||
Reference in New Issue
Block a user