Main
Script library

Here are functions and classes that can be used for: getting informations from .html files, processing loading and saving text data and program's command line arguments, making operations on date and time, processing text outputs of system's command line programs, and making small script like programs.


Sources and compiled library on Windows XP, MinGW: script.zip (size: 39 KB, last modified: 2007/05/04).

used types in declarations:
typedef unsigned int uint;
typedef std :: string Str;
typedef std :: string :: size_type strI;
typedef std :: vector< Str > strVector;
typedef char chr;

function/class declaration
description
usage
struct HTMLData;
(functional structure) For reading html text data.
example
bool isstrspace( const Str &str ); Check if str is made from white chars or is empty.
example
bool isstrsep( const Str &str, chr *sep ); Check if str is made from separators chars or is empty.
example
bool cmpStrA( const Str &str1, strI pos, const Str &str2 ); Compare str1 and str2 from str1[ pos ] without distinguish big and small letters. Return 0 if equal.
example
uint loadFile( chr *fName, Str &buf ); Fill buf with text data from file, return size of buf.
example
void saveFile( chr *fName, chr *buf, bool m ); Save buf to text file, mode m: 1 append, 0 create new file.
example
uint strprintf( Str &str, const chr *fmt, ... ); Function sprintf for string output, return size of fmt
example
bool isseparator( chr c, chr *separators ); Check if c is in separotor list.
example
struct GetStringFF;
(functional structure) Get string before separators, from file. Return size of string.
example
uint getString( chr direction, const Str &buf, strI &bp, Str &word, chr *separators ); Get n-th word, previous (direction < 0) or next (direction > 0), separeted by separators and changes buf pos, return word size.
example
uint getDigits( chr direction, const Str &buf, strI &bp, Str &nr ); Get n-th number (string made from digits), previous (direction < 0) or next (direction > 0), changes buf pos, return nr size.
example
uint strReplace( Str &buf, chr *str1, chr *str2 ); Replace every str1 to str2 in buf.
example
bool isset( const Str &s1, const Str &s2, chr *sep ); Check if set of strings (separeted by sep) from s2 are in s1.
example
bool isequalset( const Str &s1, const Str &s2, chr *sep ); Check if set of strings s1 is equal to set2.
example
void clearstr( Str &str, chr *sep ); Clear str from unnecessary separators.
example
void systemStr( const chr *command, Str &buf ); Run system( command ) and place output text in the buffer.
example
bool isArg( chr **argv, chr *sw ); Check if program argument have specified switch.
example
bool isArg( const Str &buf, chr *sw, chr *sep ); Check if buf have specified switch.
example
bool checkQuotes( Str &word, const Str &buf, strI &bp, chr *qchrs ); Fill word with quoted string from buf[ bp ] (if word starts with quotes chars).
example
uint getArgStr( chr **argv, chr *sw, strVector &v, chr *swSep ); Get program argument placed after specified switch (sw) and puts it to str vector, returns size of created vector.
example
uint getArgStr( const Str &buf, chr *sw, strVector &v, chr *argSep, chr *swSep ); Get argument from buf placed after specified switch (sw) and put it to str vector (arguments are separeted by argSep chars and switches are separated by swSep chars), returns size of created vector.
example
strI rfind_first_not_of( const Str &buf, strI bp, chr *sep ); Reverse find first not of chars from sep, returns position or NPOS when is not found.
example
strI rfind_last_not_of( const Str &buf, strI bp, chr *sep ); Reverse find last not of chars from sep, returns position.
example
strI rfind_first_of( const Str &buf, strI bp, chr *sep ); Reverse find first of chars from sep, returns position or NPOS when is not found.
example
strI find_last_not_of( const Str &buf, strI bp, chr *sep ); Slightly different results than buf.find_last_not_of( sep, bp ); method.
example
strI find_first_not_of_digit( const Str &buf, strI bp ); Similar to find_first_not_of but for digits chars.
example
strI find_first_of_digit( const Str &buf, strI bp ); Similar to find_first_of but for digits chars.
example
strI find_last_of_digit( const Str &buf, strI bp ); Similar to find_last_of but for digits chars.
example
strI rfind_last_not_of_digit( const Str &buf, strI bp ); Similar to rfind_last_not_of but for digits chars.
example
strI rfind_last_of_digit( const Str &buf, strI bp ); Similar to rfind_last_of but for digits chars.
example
strI rfind_first_not_of_digit( const Str &buf, strI bp ); Similar to rfind_first_not_of but for digits chars.
example
strI rfind_first_of_digit( const Str &buf, strI bp ); Similar to rfind_first_of but for digits chars.
example
int areDigits( const Str &str, chr *sep ); Check if str has digits ( out: -1 digits & other signs, 0 no digits, 1 only digits & sep ).
example
int areLetters( const Str &str, chr *sep ); Check if str has letters ( out: -1 letters & other signs, 0 no letters, 1 only letters & sep ).
example
int areAN( const Str &str, chr *sep ); Check if str has alnum ( out: -1 alnum & other signs, 0 no alnum, 1 only alnum & sep ).
example
void strToLower( Str &str ); Change str to lower letters.
example
void strToUpper( Str &str ); Change str to upper letters.
example
struct Date;
Operations on date and time.
example
Hosted by www.Geocities.ws

1