#undef BB
#undef BBStr
#undef bb
#undef bbStr
#define BB
#define BBStr( x,y,z ) ;
#define bb
#define bbStr( x,y,z ) ;
#ifndef procNestOn
#undef LB_
#undef LE_
#undef LE_ret
#undef ret
#undef ret_
#undef __
#undef ___
#define LB_( x )
{
#define LE_
}
#define ret_ return ;
#define LE_ret( x ) return( x );
#define ret( x ) return( x );
#define __
#define ___
#endif
/* Module ut/rbuffer rbuffer.ic
*****************************************************************************
Authors GRT ALL
*/
#include for_spu.h
#include str_set.h : cpp
#define RS 32
#define PREL 1000
#define sBufL ( 30 * 4096 ) // 15 * ... war ok
#define BufL ( 90 * 4096 ) // == 3 * sBufL
use_class str_set ;
use_struct match_rec ;
#define offset_( n, Ba )
{
B.a = Ba ; offset = n ; continue ;
}
class rBuffer
: EStandardServices /* _____________________________________________________________________________ R e u s e . f o r . ALL to make scanning text files an easy task. _____________________________________________________________________________ */ { public: unsigned long ii ; // number of find calls so far path file ; // int f ; // the open file int errors ; // number of syntax errors found BOOL checkMe ; // if NULL in z[a..e[ then fErr BOOL traceMe ; // BOOL ers_umlaute ; // expandiere Umlaute BOOL ers_upper_to_lower ; // mache alles zu lower case char * exp_umlaute ; // expandiere Umlaute int fNr ; // anz find() Aufrufe int ateof ; // int a,e ; // current buffer = z[ a .. e-1 ] int s,j ; // cursors int anf_rem ; // char * z_merke ; // char * z ; // z[ ] char info[ 300 ] ; // comments char * atStr ; // see rBuffer::find(, str_set, ) char * getmore( ) { return getmore( -1, "" ); } // char * getmore( int notw ) { if ( e <= a + notw ) return getmore(); } void getmore( int notw ) { if ( e <= a + notw ) getmore(); } protected: private: #define rB_( B,a,b,c ) { if ( ! (B).find( a,b,c ) ) fErr1( b ) }
struct  array_c
top . is_inc_for . C++
{ array_c :: array_c(); int nxt ; // next free position in c int no_pos ; // int no_c ; // int * pos ; // array of no_pos elements char * c ; // array of no_c elements } ; BOOL skipUtfNULL ; // wenn Utf coded BOOL ers_unicode ; // ersetze unicode BOOL out_at_work ; // out must not be called recursively int from_a ; // last a in 'find_...' int from_a_anz ; // last a in 'find_...' int max_e ; // maximal possible e int tab_L ; // current tab length long corrPos ; char * eofMarker ; array_c arr ; // exported methods: public: rBuffer :: rBuffer( // ----------------------------------------------------------------------------- ) ; public: rBuffer :: rBuffer // ----------------------------------------------------------------------------- ( char * src , char * dest , FILE * & opn_dest , char * prefix ) ; public: rBuffer :: rBuffer // ----------------------------------------------------------------------------- ( char * file , char * prefix // "\n" when searching for "\n..." ) ; public: rBuffer :: rBuffer // ----------------------------------------------------------------------------- ( char * str1 , char * str2 , BOOL norm ) ; public: ~rBuffer( // ----------------------------------------------------------------------------- ) ; public: void rBuffer :: syntax_error // ----------------------------------------------------------------------------- ( char * err , char * in_text ) ; public: BOOL rBuffer :: rm_unicode // ----------------------------------------------------------------------------- // unicode to iso // ----------------------------------------------------------------------------- ( char * x , uchar c1 , uchar c2 , uchar c3 ) ; public: void rBuffer :: unicode ( // ----------------------------------------------------------------------------- ) ; public: void rBuffer :: no_utf ( // ----------------------------------------------------------------------------- ) ; public: void rBuffer :: no_komma ( // ----------------------------------------------------------------------------- ) ; public: void rBuffer :: rocc /* ----------------------------------------------------------------------------- remove + open + close + create ----------------------------------------------------------------------------- */ ( char * f1 , char * f2 // file to open in rBuffer, char * str , FILE * & f // close f, then f = create( f3 ), char * f3 ) ; public: void rBuffer :: syntax_error // ----------------------------------------------------------------------------- ( char * err , char * in_text , char * at ) ; public: void rBuffer :: exp_Umlaute /* ----------------------------------------------------------------------------- transform z[ a_raw .. e-1 ] ----------------------------------------------------------------------------- */ ( char * to_code , int a_raw ) ; public: void rBuffer :: exp_Umlaute /* ----------------------------------------------------------------------------- transform z[ a_raw .. e-1 ] ----------------------------------------------------------------------------- */ ( char * nur , char * to_code , int a_raw ) ; public: void rBuffer :: scan_str // ----------------------------------------------------------------------------- ( char * from , int anz_chars , char * prefix ) ; public: void rBuffer :: open_rBuffer /* ----------------------------------------------------------------------------- Use this open_rBuffer() for reading text appended to a *.exe file. ----------------------------------------------------------------------------- */ ( long offset , char * fn , char * prefix // or NULL ) ; public: int rBuffer :: restTrace // ----------------------------------------------------------------------------- ( char * str , char * nam ) ; public: void rBuffer :: close_rBuffer( // ----------------------------------------------------------------------------- ) ; public: void rBuffer :: reopen_rBuffer // ----------------------------------------------------------------------------- ( char * fn , char * prefix // or NULL ) ; public: void rBuffer :: open_rBuffer // ----------------------------------------------------------------------------- ( char * fn , char * prefix // or NULL ) ; public: void rBuffer :: show_rest( /* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ ) ; public: uint rBuffer :: remember ( uint anz_rem /* ----------------------------------------------------------------------------- remember anz_rem positions preceeding z[a] ----------------------------------------------------------------------------- */ ) ; public: char * rBuffer :: getmore /* ----------------------------------------------------------------------------- Shift the buffer (as a window into the file) to contain more data not yet processed, then mark the end of the buffer by 'ende. ----------------------------------------------------------------------------- */ ( char * & c , int notw , char * ende ) ; public: char * rBuffer :: getmore /* ----------------------------------------------------------------------------- Shift the buffer (as a window into the file) to contain more data not yet processed. ----------------------------------------------------------------------------- */ ( int notw , char * ende ) ; public: void rBuffer :: noCase ( /* ----------------------------------------------------------------------------- nur aktivieren, wenn man alles to_lower sehen m”chte ----------------------------------------------------------------------------- */ ) ; public: BOOL rBuffer :: has_NULL ( /* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ ) ; public: char rBuffer :: preChar( char * str // ----------------------------------------------------------------------------- ) ; public: BOOL rBuffer :: rest_s_gr /* ----------------------------------------------------------------------------- return(" still more than n chars after z[s] ") ----------------------------------------------------------------------------- */ ( int n // ret BOOL( "more than n bytes left" ) ) ; public: BOOL rBuffer :: rest( // ----------------------------------------------------------------------------- ) ; public: void rBuffer :: trace // ----------------------------------------------------------------------------- ( char * name , FILE * f // soll geschrieben werden nach ) ; public: void rBuffer :: out // ----------------------------------------------------------------------------- ( int at // __LINE__ ) ; public: void rBuffer :: out // ----------------------------------------------------------------------------- ( int at //, char c // 'a' or 's', int anz // ) ; public: void rBuffer :: to ( FILE * f /* ----------------------------------------------------------------------------- append rest of buffered file to a stream fs , return number of bytes written to fs ----------------------------------------------------------------------------- */ ) ; public: void rBuffer :: copy_to_close ( FILE * f // ----------------------------------------------------------------------------- ) ; public: void rBuffer :: copy_to ( FILE * fs /* ----------------------------------------------------------------------------- append rest of buffered file to a stream fs , return number of bytes written to fs ----------------------------------------------------------------------------- */ ) ; public: void rBuffer :: rest_to /* ----------------------------------------------------------------------------- append str and then rest of buffered file to open file f ----------------------------------------------------------------------------- */ ( char * str , char * c , FILE * f ) ; public: void rBuffer :: done_DEL // ----------------------------------------------------------------------------- ( FILE * f , char * neu , char * tm1 ) ; public: char * rBuffer :: next_ersetze /* ----------------------------------------------------------------------------- */ ( FILE * f , char * str1 , char * str2 ) ; public: char * rBuffer :: next_ersetze /* ----------------------------------------------------------------------------- */ ( int offs , FILE * f , char * str1 , char * str2 ) ; public: void rBuffer :: select /* ----------------------------------------------------------------------------- select a section to f ----------------------------------------------------------------------------- */ ( FILE * f , char * str1 , char * str2 , char * str3 ) ; public: char * rBuffer :: string_at /* ----------------------------------------------------------------------------- Pre-condition: This is an rBuffer( str1, str2, true ) seen as a keystring. Note: If str1 as well as str2 are itself keystrings, and if some keys present in str2 are also present in str1 , the str1 is information superseding str2 . The string returned is - either the default_2 (if at is not present as a key), - or the default_1 (if at is present as a key but has no value assigned to it at its first occurrance), - the value assigned to the key at otherwise (again the first occurrance considered). ----------------------------------------------------------------------------- */ ( char * at , char * default_1 , char * default_2 ) ; public: void rBuffer :: reset( /* ----------------------------------------------------------------------------- Show file( 0.. ) in z and reset a = s = 0 . ----------------------------------------------------------------------------- */ ) ; public: BOOL rBuffer :: match /* ----------------------------------------------------------------------------- return BOOL( c ist element of set[ 0 .. n [ ) ----------------------------------------------------------------------------- */ ( char c , char * set // a set of characters, int n // the first n characters in this set ) ; public: char * rBuffer :: find /* ----------------------------------------------------------------------------- Is to search for a string str , and is to set s = position of string so that then z[ s.. ] = str . In case of wto != 0 , everything in front of it is written to the file wto , and a ist set to s . ret( 0 ) means "string not found" ----------------------------------------------------------------------------- */ ( int p // offset, char * str // string to search for, FILE * wto // file open for writing ) ; public: match_rec * rBuffer :: find /* ----------------------------------------------------------------------------- Is to search for the next character 'c' such that func[c] = true. return 0 if not found ----------------------------------------------------------------------------- */ ( int p // offset, str_set & strset //, FILE * wto // file open for writing ) ; public: char * rBuffer :: s_to_not_Blank /* ----------------------------------------------------------------------------- Is to search for the next non-empty character and is to identify the smallest "oms_string" starting with this character. We search until eos (in case of eos = '\n' empty lines will be skipped however). return( 0 ) means: "string not found" ----------------------------------------------------------------------------- */ ( int p // offset, FILE * wto // file open for writing, char eos // end of search space ) ; public: void rBuffer :: exp_incs /* ----------------------------------------------------------------------------- expand recursively all includes escaped by the given esc symbol ----------------------------------------------------------------------------- */ ( char * esc , char * to // the expanded file, char * umlaute // 0, two_chars, rtf_chars, ... ) ; public: void rBuffer :: step // ----------------------------------------------------------------------------- ( char * x , FILE * f ) ; public: void rBuffer :: skip // ----------------------------------------------------------------------------- ( int offset , char * str ) ; public: char * rBuffer :: skip_HTM_or_XML /* ----------------------------------------------------------------------------- <str ... </str> // end of nest | | c (ein) c (aus) ----------------------------------------------------------------------------- */ ( BOOL trace , int offset , char * c // muss im ersten <str ...> stehen: aber nur irgendwo dort, char * str ) ; public: void rBuffer :: skipComment /* ----------------------------------------------------------------------------- Der Aufrufer sagt: z[ a.. ] = "/... " oder "/..." - skip this comment if z[ a+1 ] is either * or / , otherwise there is no comment to skip. In case of "/. ... " we assume that the next "./" means the end of this comment - i.e. we do not test whether the comment contains this as a substring (which m i g h t be the case)! Die Funktion garantiert: ok || fErr ----------------------------------------------------------------------------- */ ( FILE * f ) ; #include rbuffer.h3 : cpp } ; #endif