1072 lines
		
	
	
		
			41 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1072 lines
		
	
	
		
			41 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
/* d4data.hpp (c)Copyright Sequiter Software Inc., 1988-1996.  All rights reserved. */
 | 
						|
 | 
						|
#ifndef __DATA4HEADER
 | 
						|
   #define __DATA4HEADER
 | 
						|
 | 
						|
#ifdef S4WIN32
 | 
						|
   #define _fmemset memset
 | 
						|
#endif
 | 
						|
#ifdef S4OS2
 | 
						|
  #ifdef __BORLANDC__
 | 
						|
     #define _fmemset memset
 | 
						|
  #endif
 | 
						|
#endif
 | 
						|
 | 
						|
#ifdef S4UNIX
 | 
						|
   #define _fmemset memset
 | 
						|
//   #define errorCode error_code
 | 
						|
//   #define optimizeWrite optimize_write
 | 
						|
//   #define sort4assignCmp sort4assign_cmp
 | 
						|
#endif
 | 
						|
 | 
						|
class S4CLASS Data4 ;
 | 
						|
class S4CLASS Index4 ;
 | 
						|
class S4CLASS Str4len ;
 | 
						|
class S4CLASS Str4ptr ;
 | 
						|
class S4CLASS Field4info ;
 | 
						|
class S4CLASS Tag4info ;
 | 
						|
class S4CLASS List4 ;
 | 
						|
class S4CLASS File4 ;
 | 
						|
class S4CLASS Tag4 ;
 | 
						|
class S4CLASS Date4 ;
 | 
						|
class S4CLASS Code4 ;
 | 
						|
class S4CLASS Str4flex;
 | 
						|
class S4CLASS Expr4
 | 
						|
{
 | 
						|
public:
 | 
						|
   EXPR4 S4PTR *expr ;
 | 
						|
 | 
						|
   Expr4()                     { expr = 0 ; }
 | 
						|
   Expr4( EXPR4 S4PTR *ex )    { expr = ex ;}
 | 
						|
   Expr4( Data4 d, char *ex );
 | 
						|
   #ifdef __TURBOC__
 | 
						|
      operator double() const { double d; expr4double2( expr, &d ) ; return d; }
 | 
						|
   #else
 | 
						|
      operator double() const { return expr4double( expr ) ; }
 | 
						|
   #endif
 | 
						|
   Data4 data() const;
 | 
						|
   void free()                { expr4free( expr ) ; expr = 0 ;}
 | 
						|
   // #ifndef S4CLIENT
 | 
						|
   //  char *key( ) ;
 | 
						|
   // #endif
 | 
						|
   //int keyLen()               { return expr4key_len( expr ) ;}
 | 
						|
   int len()                  { return expr4len( expr ) ;}
 | 
						|
   int parse( Data4 d, char *ex);
 | 
						|
   int isValid() const        { return expr != 0  ;  }
 | 
						|
   const char S4PTR*source() const  { return expr4source( expr ) ;}
 | 
						|
   const char S4PTR*str() {return expr4str(expr);}
 | 
						|
   #ifdef S4USE_TRUE
 | 
						|
      int true()                 { return expr4true( expr ) ;}
 | 
						|
   #else
 | 
						|
      int isTrue()               { return expr4true( expr ) ;}
 | 
						|
   #endif
 | 
						|
   int type()                 { return expr4type( expr ) ;}
 | 
						|
   char *vary( ) {char *result; int rc; rc=expr4vary(expr, &result); return result;}
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Code4 : public CODE4
 | 
						|
{
 | 
						|
protected:
 | 
						|
   MEM4 *string_types[16] ;
 | 
						|
   friend class Str4flex ;
 | 
						|
public:
 | 
						|
   Code4( int initialize = 1 ) { if( initialize ) init() ; }
 | 
						|
 | 
						|
   Code4( Code4& ) ;         /* Illegal operation, force link error */
 | 
						|
   operator =(Code4 &) ;     /* Illegal operation, force link error */
 | 
						|
 | 
						|
   int   calcCreate( Expr4 ex, char *name )
 | 
						|
                               { return (code4calcCreate( this, ex.expr, name )) ? r4success:-1; }
 | 
						|
   void  calcReset()           { code4calcReset( this ) ; }
 | 
						|
   int   closeAll()            { return code4close( this ) ; }
 | 
						|
#ifdef S4CLIENT
 | 
						|
   int   connect( S4CONST char *serverId=DEF4SERVER_ID,
 | 
						|
                  S4CONST char *processId=DEF4PROCESS_ID,
 | 
						|
                  S4CONST char *userName = "PUBLIC",
 | 
						|
                  S4CONST char *password = 0,
 | 
						|
                  S4CONST char *protocol = (char *)PROT4DEFAULT )
 | 
						|
                               { return code4connect( this, serverId, processId, userName, password, protocol ) ; }
 | 
						|
#endif
 | 
						|
   Data4 data( char *alias );
 | 
						|
   const char S4PTR* dateFormat()
 | 
						|
                               { return code4dateFormat( this ) ; }
 | 
						|
   int   dateFormat( const char *format )
 | 
						|
                               { return code4dateFormatSet( this, format ) ; }
 | 
						|
   int   error( const int er, const long er2 = 0L, const char *p1=0,
 | 
						|
                const char *p2 = 0, const char *p3 = 0 )
 | 
						|
                       { return error4describe( this, er, er2, p1, p2, p3 ) ; }
 | 
						|
   int errorFile(char *fileName, int overwrite=1)
 | 
						|
                    { return error4file(this,fileName,overwrite);}
 | 
						|
   int   errorSet(int c=0 ){ return error4set( this, c ) ; }
 | 
						|
 | 
						|
   const char S4PTR* errorText(const long c )
 | 
						|
                               { return error4text( this, c ) ; }
 | 
						|
   void  exit()                { code4exit( this ) ; }
 | 
						|
   void  exitTest()            { error4exitTest( this ) ; }
 | 
						|
   int   flushFiles()          { return code4flush( this ) ; }
 | 
						|
   const char S4PTR* indexExtension()
 | 
						|
                               { return code4indexExtension( this ) ; }
 | 
						|
   inline int   init();
 | 
						|
   int   initUndo()            { return code4initUndo( this ) ; }
 | 
						|
   int   lock()                { return code4lock( this ) ; }
 | 
						|
   void   lockClear()           { code4lockClear( this ) ; }
 | 
						|
   const char *lockFileName() {return code4lockFileName(this);}
 | 
						|
   long  lockItem()            { return code4lockItem( this ) ; }
 | 
						|
   #ifdef S4CLIENT
 | 
						|
      const char S4PTR* lockUserId( )
 | 
						|
                               { return code4lockUserId( this ) ;}
 | 
						|
      const char S4PTR* lockNetworkId( )
 | 
						|
                               { return code4lockNetworkId( this ) ; }
 | 
						|
   #endif
 | 
						|
#ifdef S4SERVER
 | 
						|
      const char S4PTR* lockUserId( )
 | 
						|
                               { return code4lockUserId( this ) ;}
 | 
						|
      const char S4PTR* lockNetworkId( )
 | 
						|
                               { return code4lockNetworkId( this ) ; }
 | 
						|
   #endif
 | 
						|
   #ifdef S4STAND_ALONE
 | 
						|
   #ifndef S4OFF_WRITE
 | 
						|
   #ifndef S4OFF_TRAN
 | 
						|
      int   logCreate( const char *name,const char *userId )
 | 
						|
                               { return code4logCreate( this, name,userId ) ; }
 | 
						|
      const char S4PTR* logFileName()
 | 
						|
                               { return code4logFileName( this ) ; }
 | 
						|
      int   logOpen( const char *name, const char *userId )
 | 
						|
                               { return code4logOpen( this, name, userId ) ; }
 | 
						|
      void   logOpenOff()       { code4logOpenOff( this ) ; }
 | 
						|
   #endif
 | 
						|
   #endif
 | 
						|
   #endif
 | 
						|
   int   optAll()  {return code4optAll(this);}
 | 
						|
   int   optStart()            { return code4optStart( this ) ; }
 | 
						|
   int   optSuspend()          { return code4optSuspend( this ) ; }
 | 
						|
   #ifndef S4DLL
 | 
						|
      void    reset( )         { mem4reset( ) ;}
 | 
						|
   #endif
 | 
						|
   long timeout()               {return code4timeout(this);}
 | 
						|
   void timeout(long l)         {code4timeoutSet(this,l);}
 | 
						|
   int   tranCommit()          { return code4tranCommit( this ) ; }
 | 
						|
   int   tranRollback()        { return code4tranRollback( this ) ; }
 | 
						|
   int   tranStart()           { return code4tranStart( this ) ; }
 | 
						|
   int   tranStatus()          { return  code4tranStatus(this); }
 | 
						|
   int   unlock()              { return code4unlock( this ) ; }
 | 
						|
   int   unlockAuto()          { return code4unlockAuto( this ) ; }
 | 
						|
   int   unlockAuto( int c )   { return code4unlockAutoSet( this, c ) ; }
 | 
						|
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Data4
 | 
						|
{
 | 
						|
public:
 | 
						|
   DATA4 S4PTR *data ;
 | 
						|
   Data4()                           { data = 0 ; }
 | 
						|
   Data4( DATA4 S4PTR*d )            { data = d ; }
 | 
						|
   Data4( Code4& code, char *name )  { data = d4open( &code, name ) ; }
 | 
						|
   operator DATA4 *()  const         { return data; }
 | 
						|
   const char   S4PTR* alias()             { return d4alias( data ) ; }
 | 
						|
   DATA4 S4PTR *dat()                { return data; }
 | 
						|
   void    alias(const char S4PTR *ptr)   { d4aliasSet(dat(),ptr) ; }
 | 
						|
   int    append()                   { return d4append( data ) ; }
 | 
						|
   int    appendBlank()              { return d4appendBlank( data ) ; }
 | 
						|
   int    appendStart( int memo = 0 ){ return d4appendStart( data, memo ) ; }
 | 
						|
   void    blank()                   {d4blank( data ) ; }
 | 
						|
   int    bof()                      { return d4bof( data ) ; }
 | 
						|
   int    bottom()                   { return d4bottom( data ) ; }
 | 
						|
   int    changed( int flag = -1 )   { return d4changed( data, flag ) ; }
 | 
						|
   int    check()                    { return d4check( data ) ; }
 | 
						|
   int    close()                    { int rc = d4close( data ) ;
 | 
						|
                                       data = 0; return rc; }
 | 
						|
   int    create( Code4& code, S4CONST char *name, S4CONST FIELD4INFO &f,
 | 
						|
                  S4CONST TAG4INFO &t)
 | 
						|
                                     { data = d4create( &code, name, &f, &t ) ;
 | 
						|
                                       return code.errorCode ; }
 | 
						|
   int    create( Code4& code, S4CONST char *name, S4CONST FIELD4INFO &f)
 | 
						|
                                     { data = d4create( &code, name, &f, 0) ;
 | 
						|
                                       return code.errorCode ; }
 | 
						|
   int    create( Code4& code, S4CONST char *name, S4CONST FIELD4INFO *f,
 | 
						|
                  S4CONST TAG4INFO *t = 0 )
 | 
						|
                                     { data = d4create( &code, name, f, t ) ;
 | 
						|
                                       return code.errorCode ; }
 | 
						|
   void    deleteRec()               { d4delete( data ) ; }
 | 
						|
   int    deleted()                  { return d4deleted( data ) ; }
 | 
						|
   int    eof()                      { return d4eof( data ) ; }
 | 
						|
   int    fieldNumber( const char *name)
 | 
						|
                                     { return d4fieldNumber( data, name) ; }
 | 
						|
   const char S4PTR* fileName()      { return d4fileName( data ) ; }
 | 
						|
   int    flush()                    { return d4flush( data ) ; }
 | 
						|
   /*  AS - no longer supported (04/23/96)
 | 
						|
   #ifndef S4CLIENT
 | 
						|
      int flushData()                { return d4flushData( data ) ; }
 | 
						|
   #endif
 | 
						|
   */
 | 
						|
   int    freeBlocks()               { return d4freeBlocks( data ) ; }
 | 
						|
   int    go( const long rec )       { return d4go( data, rec ) ; }
 | 
						|
   int    goBof()                    { return d4goBof( data ) ; }
 | 
						|
   int    goEof()                    { return d4goEof( data ) ; }
 | 
						|
   Index4 index( const char *name);
 | 
						|
   int    isValid( )                 { return data != 0 ; }
 | 
						|
   int    lock( const long rec_num ) { return d4lock( data, rec_num ) ; }
 | 
						|
   int    lockAdd( long recnum )     { return d4lockAdd( data, recnum ) ; }
 | 
						|
   int    lockAddAppend()            { return d4lockAddAppend( data ) ; }
 | 
						|
   int    lockAddFile()              { return d4lockAddFile( data ) ; }
 | 
						|
   int    lockAddAll()      {return d4lockAddAll(data);}
 | 
						|
   int lockAll()                  { return d4lockAll( data ) ; }
 | 
						|
 | 
						|
   int    lockAppend()               { return d4lockAppend( data ) ; }
 | 
						|
   int    lockFile()                 { return d4lockFile( data ) ; }
 | 
						|
 | 
						|
/*
 | 
						|
 * d4lockTest... functions are no longer available
 | 
						|
 *
 | 
						|
 * int    lockTest( const long rec ) { return d4lockTest( data, rec ) ; }
 | 
						|
 * int    lockTestAppend()           { return d4lockTestAppend( data ) ; }
 | 
						|
 * int    lockTestFile()             { return d4lockTestFile( data ) ; }
 | 
						|
 * #ifndef S4CLIENT
 | 
						|
 *    int lockTestIndex()            { return d4lockTestIndex( data ) ; }
 | 
						|
 * #endif
 | 
						|
 */
 | 
						|
 | 
						|
   int    log(int l)                 { return d4log( data, l) ; }
 | 
						|
   int    log()                      { return d4log( data, -1 ) ; }
 | 
						|
   int    memoCompress()             { return d4memoCompress( data ) ; }
 | 
						|
   int    numFields()                { return d4numFields( data ) ; }
 | 
						|
   int    open( Code4 &code, S4CONST char *name )
 | 
						|
                                     { data =  d4open( &code, name ) ;
 | 
						|
                                       return ( code.errorCode < 0 ? code.errorCode : 0 ) ; }
 | 
						|
   inline int    openClone( Data4 d );
 | 
						|
   int    optimize( const int opt_flag )
 | 
						|
                                     { return d4optimize( data, opt_flag ) ; }
 | 
						|
   int    optimizeWrite( const int opt_flag )
 | 
						|
                                     { return d4optimizeWrite( data,  opt_flag ) ; }
 | 
						|
   int    pack()                     { return d4pack( data ) ; }
 | 
						|
   #ifdef __TURBOC__
 | 
						|
      double position()              { double d; d4position2( data, &d ) ;
 | 
						|
                                       return d; }
 | 
						|
   #else
 | 
						|
      double position()              { return d4position( data ) ; }
 | 
						|
   #endif
 | 
						|
   int    position( const double pos ){ return d4positionSet( data, pos ) ; }
 | 
						|
   void   recall()                   { d4recall( data ) ; }
 | 
						|
   long   recCount()                 { return d4recCount( data ) ; }
 | 
						|
   long   recNo()                    { return d4recNo( data ) ; }
 | 
						|
   char   S4PTR* record()            { return d4record( data ) ; }
 | 
						|
   //long   recPosition( const long r ){ return d4recPosition( data, r ) ; }
 | 
						|
   unsigned int recWidth()           { return d4recWidth( data ) ; }
 | 
						|
   int    refresh()                  { return d4refresh( data ) ; }
 | 
						|
   int    refreshRecord()            { return d4refreshRecord( data ) ; }
 | 
						|
   int    reindex()                  { return d4reindex( data ) ; }
 | 
						|
   int    remove()                   {return d4remove(data);}
 | 
						|
   int    seek( S4CONST char *ptr )  { return d4seek( data, ptr ) ; }
 | 
						|
   int    seek( S4CONST char *ptr, const int len )
 | 
						|
                                     { return d4seekN( data, ptr, len ) ; }
 | 
						|
   int    seek( S4CONST double d )   { return d4seekDouble( data, d ) ; }
 | 
						|
   #ifndef S4CB51
 | 
						|
   int    seekNext( const char *ptr ){ return d4seekNext( data, ptr ) ; }
 | 
						|
   int    seekNext( const char *ptr, const int len )
 | 
						|
                                     { return d4seekNextN( data, ptr, len ) ; }
 | 
						|
   int    seekNext( const double d ) { return d4seekNextDouble( data, d ) ; }
 | 
						|
   #endif
 | 
						|
   void    select()                   {d4tagSelect( data, 0 ) ; }
 | 
						|
   void    select( Tag4 tag ) ;
 | 
						|
   void    select( const char *tagName );
 | 
						|
   int    skip( const long n = 1 )   { return d4skip( data, n ) ; }
 | 
						|
   int    tagSync()                  { return d4tagSync( data, d4tagSelected( data ) ) ; }
 | 
						|
   int    top()                      { return d4top( data ) ; }
 | 
						|
   int    unlock()                   { return d4unlock( data ) ; }
 | 
						|
   int    write( long rec = -1 )     {  return d4write( data,rec);}
 | 
						|
   int    zap( long f = 1, long last = 1000000000L)
 | 
						|
                                     { return d4zap( data, f, last ) ; }
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Index4
 | 
						|
{
 | 
						|
public:
 | 
						|
   INDEX4 S4PTR *index ;
 | 
						|
public:
 | 
						|
   Index4()                          { index = 0 ; }
 | 
						|
   Index4( INDEX4 S4PTR *in )        { index = in ; }
 | 
						|
   Index4( Data4 d, S4CONST char *name )
 | 
						|
                                     { index = i4open( d.dat(), name ) ; }
 | 
						|
   int    close()                    { int rc =  i4close( index ) ;
 | 
						|
                                       index = 0 ; return rc;}
 | 
						|
   int    create( Data4 d, S4CONST char *name, S4CONST TAG4INFO *info )
 | 
						|
                                     { index = i4create( d.dat(), name, info ) ;
 | 
						|
                                       return d.dat()->codeBase->errorCode ; }
 | 
						|
   int    create( Data4 d, S4CONST TAG4INFO *info )
 | 
						|
                                     { index = i4create( d.dat(), 0, info ) ;
 | 
						|
                                       return d.dat()->codeBase->errorCode ; }
 | 
						|
   int    create( Data4 d, S4CONST char *name, S4CONST Tag4info& info );
 | 
						|
 | 
						|
   int    create( Data4 d, S4CONST Tag4info& info );
 | 
						|
 | 
						|
   Data4  data()                     { return Data4( index->data ) ; }
 | 
						|
   const  char S4PTR* fileName()     { return i4fileName( index ) ; }
 | 
						|
   void   init( Data4 d, const char *name )
 | 
						|
                                     { index = d4index(d.dat(), name ); }
 | 
						|
   int    isValid()                  { return index!=0;}
 | 
						|
   int    open( Data4 d, S4CONST char *file = NULL )
 | 
						|
                                     { index = i4open( d.dat(), file ) ;
 | 
						|
                                       return d.dat()->codeBase->errorCode ; }
 | 
						|
   int    reindex()                  { return i4reindex( index ) ; }
 | 
						|
   Tag4   tag( char *name );
 | 
						|
   int    tagAdd( const TAG4INFO *newTag )
 | 
						|
                                     { return i4tagAdd( this->index, newTag ) ; }
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Tag4
 | 
						|
{
 | 
						|
 | 
						|
public:
 | 
						|
   TAG4 S4PTR *tag;
 | 
						|
   Tag4()                      { tag = NULL ; }
 | 
						|
   Tag4( TAG4 S4PTR *tg )      { tag = tg ; }
 | 
						|
   Tag4( Data4 d, const char * const name = NULL )
 | 
						|
                               { tag = d4tag( d.dat(), name ) ;}
 | 
						|
   operator TAG4*() const      { return tag ; }
 | 
						|
   #ifndef S4SERVER
 | 
						|
      char S4PTR* alias()      { return t4alias( tag ) ; }
 | 
						|
   #else
 | 
						|
      char S4PTR* alias()      { return tag->tagFile->alias ; }
 | 
						|
   #endif
 | 
						|
   #ifdef S4CLIPPER
 | 
						|
       int close() {return t4close(tag);}
 | 
						|
   #endif
 | 
						|
   #ifdef S4NDX
 | 
						|
      int close() {return t4close(tag);}
 | 
						|
   #endif
 | 
						|
   #ifndef S4CLIENT
 | 
						|
   int descending() {return tfile4isDescending(tag->tagFile);}
 | 
						|
   #endif
 | 
						|
   //#ifndef S4SERVER
 | 
						|
      const char S4PTR* expr() { return t4expr(tag) ; }
 | 
						|
      const char S4PTR* filter()
 | 
						|
                               { return t4filter(tag) ; }
 | 
						|
   //#else
 | 
						|
   //    const char S4PTR* expr() { return tag->tagFile->expr ; }
 | 
						|
   //   const char S4PTR* filter()
 | 
						|
   //                            { return tag->tagFile->filter ; }
 | 
						|
   //#endif
 | 
						|
   //Index4 index()              { return Index4(tag->index) ; }
 | 
						|
   void   init( Data4 d, const char *name = NULL ) ;
 | 
						|
   //void   initDefault( Data4 d ){ tag = d4tagDefault( d.dat() ) ; }
 | 
						|
   void   initFirst( Data4 d ) { tag = d4tagNext( d.dat(), NULL ) ; }
 | 
						|
   void   initLast( Data4 d )  { tag = d4tagPrev( d.dat(), NULL ) ; }
 | 
						|
   void   initNext( )          { if( isValid( ) ) tag = d4tagNext( tag->index->data, tag ) ; }
 | 
						|
   void   initPrev( )          { if( isValid( ) ) tag = d4tagPrev( tag->index->data, tag ) ; }
 | 
						|
   void   initSelected( Data4 d )
 | 
						|
                               { tag = d4tagSelected( d.dat() ) ; }
 | 
						|
   int    isValid()            { return tag!=0; } ;
 | 
						|
   #ifdef N4OTHER
 | 
						|
      // open() is only supported for N4OTHER
 | 
						|
      void    open( Data4 d, char *name )
 | 
						|
                                  { tag = t4open( d.dat(), NULL, name ); }
 | 
						|
      void    open( Data4 d, Index4 i, char *name )
 | 
						|
                                  { tag = t4open( d.dat(), i.index, name) ; }
 | 
						|
   #endif
 | 
						|
   int    unique()             { return t4unique( tag ) ; }
 | 
						|
   int    unique( const int unique_code )
 | 
						|
                               { return t4uniqueSet( tag, unique_code ) ; }
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Str4len ;
 | 
						|
 | 
						|
class S4CLASS Str4
 | 
						|
{
 | 
						|
public:
 | 
						|
   #ifdef __ZTC__
 | 
						|
      virtual operator char() ;
 | 
						|
      virtual operator double() ;
 | 
						|
      virtual operator int() ;
 | 
						|
   #else
 | 
						|
      operator char() ;
 | 
						|
      operator double() ;
 | 
						|
      operator int() ;
 | 
						|
   #endif
 | 
						|
   virtual operator long() ;
 | 
						|
   char& operator[]( int index ) ;
 | 
						|
   int  operator==( Str4& ) ;  /* Equal, including length */
 | 
						|
   int  operator!=( Str4& s ) { return ! operator==(s) ; }
 | 
						|
   int  operator< ( Str4& ) ;
 | 
						|
   int  operator> ( Str4& ) ;
 | 
						|
   int  operator>=( Str4& s ) { return ! operator<(s) ; }
 | 
						|
   int  operator<=( Str4& s ) { return ! operator>(s) ; }
 | 
						|
   int  add( Str4& ) ;
 | 
						|
   int  add( char *) ;
 | 
						|
   int  assign( const char S4PTR * ) ;
 | 
						|
   int  assign( const char S4PTR *ptr,const unsigned ptr_len ) ;
 | 
						|
   int  assign( const Str4& str_from ) ;
 | 
						|
   void assignDouble( double, int new_len = -1, int n_dec = -1 ) ;
 | 
						|
   void assignLong( long, int new_len = -1, int zeros_in_front = 0 ) ;
 | 
						|
   int  at( Str4& ) ;
 | 
						|
   int  encode( char *, char *, char * ) ;
 | 
						|
   char *endPtr() ;
 | 
						|
   int  insert( Str4&, unsigned pos= 0 ) ;
 | 
						|
   void lower() ;
 | 
						|
   unsigned ncpy( char *to_ptr, unsigned to_len ) ;
 | 
						|
   int  replace( Str4&, unsigned pos= 0 ) ;
 | 
						|
   void set( int chr_value ) ;
 | 
						|
   void trim() ;
 | 
						|
   void upper() ;
 | 
						|
 | 
						|
   /* Get information */
 | 
						|
   const Str4len left( unsigned l ) const;
 | 
						|
   const Str4len right( unsigned l ) const;
 | 
						|
   const Str4len substr( unsigned pos, unsigned result_len ) const;
 | 
						|
   #ifdef S4USE_TRUE
 | 
						|
      int true() ;
 | 
						|
   #else
 | 
						|
      int isTrue() ;
 | 
						|
   #endif
 | 
						|
   virtual void      changed()          {}
 | 
						|
   virtual int       decimals()         { return 0 ; }
 | 
						|
   virtual unsigned  len() ;
 | 
						|
   virtual unsigned len1() const;
 | 
						|
   #ifndef S4OFF_ENFORCE_LOCK
 | 
						|
      // Returns r4success if its ok, otherwise returns -1
 | 
						|
      virtual int    lockCheck()        { return r4success ; }
 | 
						|
   #endif
 | 
						|
   virtual unsigned  maximum()         { return len() ; }
 | 
						|
   virtual char      S4PTR*ptr()  = 0 ;
 | 
						|
   virtual const char      S4PTR*ptr1() const  = 0 ;
 | 
						|
   virtual const char      S4PTR*str() ;
 | 
						|
   virtual int       setLen(unsigned)  { return -1 ; }
 | 
						|
   virtual int       setMax(unsigned)  { return -1 ; }
 | 
						|
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Str4char : public Str4
 | 
						|
{
 | 
						|
public:
 | 
						|
   Str4char( char ch = 0 ) ;
 | 
						|
   char     S4PTR*ptr()       { return &c ; }
 | 
						|
   char     const S4PTR*ptr1() const      { return &c ; }
 | 
						|
   unsigned len()             { return 1 ; }
 | 
						|
   unsigned len1() const             { return 1 ; }
 | 
						|
 | 
						|
private:
 | 
						|
   char c ;
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Str4ptr : public Str4
 | 
						|
{
 | 
						|
public:
 | 
						|
   Str4ptr( char *ptr )        { p =   ptr ; }
 | 
						|
   char S4PTR*ptr()             { return p ; }
 | 
						|
   char const S4PTR*ptr1() const             { return p ; }
 | 
						|
   char *p ;
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Str4len : public Str4ptr
 | 
						|
{
 | 
						|
public:
 | 
						|
   Str4len( const void *ptr, unsigned ptr_len ) : Str4ptr((char *)ptr)
 | 
						|
                               { curLen =  ptr_len; }
 | 
						|
   unsigned len()              { return curLen ; }
 | 
						|
   unsigned len1() const              { return curLen ; }
 | 
						|
   unsigned curLen ;
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Str4max : public Str4len
 | 
						|
{
 | 
						|
public:
 | 
						|
   Str4max( void *ptr, unsigned m ) : Str4len(ptr,m)
 | 
						|
                               { maxLen = m; }
 | 
						|
 | 
						|
   unsigned maximum()          { return maxLen ; }
 | 
						|
   int      setLen( unsigned) ;
 | 
						|
 | 
						|
   unsigned maxLen ;
 | 
						|
 | 
						|
} ;
 | 
						|
 | 
						|
/* The following classes  are always guaranteed to be null ended. */
 | 
						|
class S4CLASS Str4ten : public Str4
 | 
						|
{
 | 
						|
public:
 | 
						|
   Str4ten()                   { curLen = 0; buf[0] = 0; buf[10] = 0; }
 | 
						|
   Str4ten( const char *p )    { curLen = 0; buf[10] = 0; assign(p); }
 | 
						|
   Str4ten( Str4 &s )          { curLen = 0; buf[10]=0; assign(s); }
 | 
						|
 | 
						|
   unsigned len()              { return curLen; }
 | 
						|
   unsigned len1() const             { return curLen; }
 | 
						|
   unsigned maximum()          { return 10 ; }
 | 
						|
   char     S4PTR*ptr()        { return buf ; }
 | 
						|
   char    const S4PTR*ptr1() const       { return buf ; }
 | 
						|
   int      setLen(unsigned new_len) ;
 | 
						|
 | 
						|
   unsigned curLen ;
 | 
						|
 | 
						|
private:
 | 
						|
   char buf[12] ;
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Str4large: public Str4
 | 
						|
{
 | 
						|
public:
 | 
						|
   Str4large() ;
 | 
						|
   Str4large( char *p );
 | 
						|
   Str4large( Str4 &s) ;
 | 
						|
 | 
						|
   unsigned maximum()     { return 255 ; }
 | 
						|
   unsigned len()     { return curLen; }
 | 
						|
   unsigned len1() const    { return curLen; }
 | 
						|
   char    S4PTR*ptr()      { return buf ; }
 | 
						|
   char    const S4PTR*ptr1() const     { return buf ; }
 | 
						|
   int      setLen(unsigned len) ;
 | 
						|
 | 
						|
   unsigned curLen ;
 | 
						|
 | 
						|
private:
 | 
						|
   char buf[256] ;
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Str4flex : public Str4max
 | 
						|
{
 | 
						|
public:
 | 
						|
   Str4flex( Code4 & ) ;
 | 
						|
   Str4flex( Str4flex& ) ;
 | 
						|
  ~Str4flex() ;
 | 
						|
   Str4flex &operator =( Str4flex &s )
 | 
						|
                               { assign( s ) ; return s ;}
 | 
						|
 | 
						|
   void   free() ;
 | 
						|
   int    setMax( unsigned ) ;
 | 
						|
   const char   S4PTR*str()          { return ptr() ; }
 | 
						|
 | 
						|
   Code4 S4PTR *codeBase ;
 | 
						|
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Field4 : public Str4
 | 
						|
{
 | 
						|
public:
 | 
						|
   Field4()                      { field =  0 ; }
 | 
						|
   Field4( Data4 d, int j )      { field =  d4fieldJ( d.dat(), j ) ; }
 | 
						|
   Field4( Data4 d, const char *name ) { field =  d4field( d.dat(), name ) ; }
 | 
						|
   Field4( FIELD4 *f )           { field =  f ; }
 | 
						|
 | 
						|
   void          assignField( Field4 f ) { f4assignField( field, f.field ) ; }
 | 
						|
   void          changed()   { d4changed(field->data, 1) ; }
 | 
						|
   Data4         data()      { return Data4( field->data ) ; }
 | 
						|
   int           decimals()  { return f4decimals(field) ; }
 | 
						|
   int           init( Data4 d, const char *name )
 | 
						|
                             { field = d4field( d.dat(), name ) ;
 | 
						|
                               return (field == 0) ? -1 : 0 ; }
 | 
						|
   int           init( Data4 d, int j )
 | 
						|
                             { field = d4fieldJ( d.dat(), j ) ;
 | 
						|
                               return (field == 0) ? -1 : 0 ; }
 | 
						|
   int           isValid() { return field!=0;}
 | 
						|
   unsigned      len()       { return f4len(field) ; }
 | 
						|
   unsigned      len1() const       { return f4len(field) ; }
 | 
						|
#ifndef S4OFF_ENFORCE_LOCK
 | 
						|
   int            lockCheck();
 | 
						|
#endif
 | 
						|
   const char         S4PTR*name()      { return f4name(field) ; }
 | 
						|
   int           number()    { return d4fieldNumber( field->data, name() ) ;}
 | 
						|
   int           type()      { return f4type(field) ; }
 | 
						|
   char         S4PTR*ptr()        { return f4ptr(field) ; }
 | 
						|
   char   const S4PTR*ptr1() const        { return f4ptr(field) ; }
 | 
						|
 | 
						|
   FIELD4    S4PTR *field ;
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Field4info
 | 
						|
{
 | 
						|
public:
 | 
						|
   Field4info( Code4 &) ;
 | 
						|
   Field4info( Data4  ) ;
 | 
						|
 | 
						|
   ~Field4info() ;
 | 
						|
   Field4info( Field4info &);  // Illegal operation, force link error
 | 
						|
   operator =(Field4info&) ;   // Illegal operation, force link error
 | 
						|
   int add( const char *, char , int len = 0, int dec = 0 ); //in f4info_p.cpp
 | 
						|
   int add( Field4 ) ;
 | 
						|
   int add( Data4 ) ;
 | 
						|
   int del( int ) ;
 | 
						|
   int del( char *) ;
 | 
						|
   void free( ) ;
 | 
						|
   FIELD4INFO *fields( ) { return field ;}
 | 
						|
   const FIELD4INFO *operator[](int index) ;
 | 
						|
   int numFields() { return size ; } ;
 | 
						|
private:
 | 
						|
   Code4 S4PTR *codeBase ;
 | 
						|
   FIELD4INFO *field ;
 | 
						|
   int size ;
 | 
						|
   unsigned length ;
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Tag4info
 | 
						|
{
 | 
						|
private:
 | 
						|
   char *expr, *filt;
 | 
						|
public:
 | 
						|
   Tag4info( Code4 &) ;
 | 
						|
   Tag4info( Data4 ) ;
 | 
						|
   Tag4info( Index4 ) ;
 | 
						|
   ~Tag4info() ;
 | 
						|
   Tag4info(Tag4info&) ;    // Illegal action, force a link error
 | 
						|
   operator =( Tag4info &) ;  // Illegal action, force a link error
 | 
						|
 | 
						|
   int  add( const char *, const char *, const char *filter = NULL, int uniq = 0, int desc = 0 );
 | 
						|
   int  add( Tag4 ) ;
 | 
						|
   int  del( int ) ;
 | 
						|
   int  del( const char * ) ;
 | 
						|
   TAG4INFO * tags( ) { return tag ; }
 | 
						|
   void free( ) ;
 | 
						|
   int  numTags() { return size ; } ;
 | 
						|
private:
 | 
						|
   int  add_index_tags( INDEX4 * ) ;
 | 
						|
   char S4PTR* getName( TAG4INFO *tagInfo, int tagPos = 0 ) ;
 | 
						|
   const char S4PTR* getExpr( TAG4INFO *tagInfo, int tagPos = 0 ) ;
 | 
						|
   const char S4PTR* getFilter( TAG4INFO *tagInfo, int tagPos = 0 ) ;
 | 
						|
   int  getUniqueKey( TAG4INFO *tagInfo, int tagPos = 0 ) ;
 | 
						|
   int  getDescendKey( TAG4INFO *tagInfo, int tagPos = 0 ) ;
 | 
						|
   Code4 S4PTR *codeBase ;
 | 
						|
   TAG4INFO *tag ;
 | 
						|
   int size ;
 | 
						|
   unsigned length ;
 | 
						|
   friend class Data4 ;
 | 
						|
   friend class Index4 ;
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Field4memo : public Field4
 | 
						|
{
 | 
						|
public:
 | 
						|
   Field4memo() ;
 | 
						|
   Field4memo( Data4& data, int j ) ;
 | 
						|
   Field4memo( Data4& data, const char *name ) ;
 | 
						|
   Field4memo( Field4 f ) ;
 | 
						|
 | 
						|
   void changed() ;
 | 
						|
   void free()       { f4memoFree(field) ; }
 | 
						|
   unsigned len()    { return f4memoLen(field) ; }
 | 
						|
   unsigned len1() const   { return f4memoLen(field) ; }
 | 
						|
   int  setLen(unsigned new_len) ;
 | 
						|
 | 
						|
   char S4PTR*ptr()        { return f4memoPtr(field) ; }
 | 
						|
   char const S4PTR*ptr1() const       { return f4memoPtr(field) ; }
 | 
						|
   const char S4PTR*str()       { return f4memoStr(field) ; }
 | 
						|
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS  Date4 : public Str4
 | 
						|
{
 | 
						|
public:
 | 
						|
   Date4() ;
 | 
						|
   Date4( long l ) ;
 | 
						|
   Date4( const char S4PTR* p) ;
 | 
						|
   Date4( char S4PTR* p, char S4PTR* pict ) ;
 | 
						|
   operator long()         { return date4long(ptr()) ; }
 | 
						|
   #ifdef __TURBOC__
 | 
						|
      operator double()    { double d;
 | 
						|
                                  date4formatMdx2( ptr(), &d );
 | 
						|
                                  return d; }
 | 
						|
   #else
 | 
						|
      operator double()    { return date4formatMdx( ptr() ); }
 | 
						|
   #endif
 | 
						|
 | 
						|
   long operator  +( const long l )    { return (date4long(ptr())+l) ; }
 | 
						|
   long operator  -( const long l )    { return (date4long(ptr())-l) ; }
 | 
						|
   void operator +=( const long l)     { date4assign( ptr(), date4long(ptr())+l ) ; }
 | 
						|
   void operator -=( const long l )    { date4assign( ptr(), date4long(ptr())-l ) ; }
 | 
						|
   long operator ++( )                 { *this+=1L ; return long(*this) ; }
 | 
						|
   long operator ++( int i)            { *this+=1L ; return long(*this)-1L ; }
 | 
						|
   long operator --( )                 { *this-=1L ; return long(*this) ; }
 | 
						|
   long operator --(int i)             { *this-=1L ; return long(*this)+1L ; }
 | 
						|
   void   assign( const long l)        { date4assign(ptr(),l) ; }
 | 
						|
   void   assign( const char *p )      { u4ncpy( ptr(), p, sizeof(dt) ) ; }
 | 
						|
   void   assign( const char *p, char *pict )
 | 
						|
                                       { date4init( ptr(), p, pict) ; }
 | 
						|
   void   assign( Str4 &s)             { Str4::assign(s) ; }
 | 
						|
   const char   S4PTR* cdow()          { return date4cdow( ptr() ) ; }
 | 
						|
   const char   S4PTR* cmonth()        { return date4cmonth(ptr()) ; }
 | 
						|
   int    day()                        { return date4day(ptr()) ; }    /* Day of month  (1-31) */
 | 
						|
   int    dow()                        { return date4dow(ptr()) ; }    /* Day of week   (1-7) */
 | 
						|
   void   format( char *result, char *pict )
 | 
						|
                                       { date4format( ptr(), result, pict ) ; }
 | 
						|
   char  *format( char *pict ) const ;
 | 
						|
   int    isLeap() const               { long y = date4year(dt) ;
 | 
						|
                                         return (y%4 == 0 && y%100 != 0 || y%400 == 0) ?  1 : 0 ; }
 | 
						|
   unsigned len()                  { return 8 ; }
 | 
						|
   unsigned len1() const                { return 8 ; }
 | 
						|
   int    month()                      { return date4month(ptr()) ; }/* Month of year (1-12) */
 | 
						|
   void   today()                      { date4today(ptr()) ; }
 | 
						|
   int    year()                       { return date4year(ptr()) ; } ;
 | 
						|
   //const char *str()
 | 
						|
   char S4PTR*ptr()                    { return  dt ; }
 | 
						|
   char const S4PTR*ptr1() const                    { return  dt ; }
 | 
						|
 | 
						|
private:
 | 
						|
   char dt[9] ;
 | 
						|
} ;
 | 
						|
 | 
						|
 | 
						|
class S4CLASS File4 : public FILE4
 | 
						|
{
 | 
						|
public:
 | 
						|
   File4() { hand = -1 ; }
 | 
						|
   File4( Code4 &code, char *namestr, int do_alloc = 0 )
 | 
						|
                               { open( code, namestr, do_alloc ) ;}
 | 
						|
   File4( File4& ) ;             /* Illegal operation, force link error */
 | 
						|
 | 
						|
   int close()                 { return file4close( this ) ; }
 | 
						|
   int create( Code4 &code, char *namestr, const int do_alloc = 0 )
 | 
						|
                               { return file4create( this, &code, namestr, do_alloc ) ; }
 | 
						|
 | 
						|
   //const char S4PTR*fileName() { return name ;}
 | 
						|
   int flush()                 { return file4flush( this ) ;}
 | 
						|
   int isValid( ) const        { return ( hand >= 0 ) ? 1 : 0 ;}
 | 
						|
   long len()                  { return file4len( this ) ; }
 | 
						|
   long len1()                 { return file4len( this ) ; }
 | 
						|
   int setLen( const long l)   { return file4lenSet( this, l ) ; }
 | 
						|
   int lock( const long start, const long bytes )
 | 
						|
                               { return file4lock( this, start, bytes); }
 | 
						|
   const char S4PTR*fileName() const {return name;}
 | 
						|
   int open( Code4 &code, S4CONST char *namestr, const int do_alloc = 0 )
 | 
						|
                               { return file4open( this, &code, namestr, do_alloc ) ; }
 | 
						|
   int optimize( const int opt_flag, const int file_type )
 | 
						|
                               { return file4optimize( this, opt_flag, file_type ) ;}
 | 
						|
   int optimizeWrite( const int opt_flag )
 | 
						|
                               { return file4optimizeWrite( this, opt_flag ) ; }
 | 
						|
   unsigned read( const long pos, void *ptr, const unsigned len )
 | 
						|
                               { return file4read( this, pos, ptr, len ) ; }
 | 
						|
   unsigned read( const long pos, Str4 &string )
 | 
						|
                               { return read( pos, (void *)string.ptr(), string.len());}
 | 
						|
   unsigned readAll( const long pos, void *ptr, const unsigned len )
 | 
						|
                               { return file4readAll( this, pos, ptr, len) ;  }
 | 
						|
   unsigned readAll( const long pos, Str4 &string )
 | 
						|
                               { return readAll( pos, (void *)string.ptr(), string.len() ) ;}
 | 
						|
   int refresh()               { return file4refresh( this ) ; }
 | 
						|
   int replace( File4 &new_file )
 | 
						|
                               { return file4replace( this, &new_file ) ;}
 | 
						|
   //int setLen (const long newLen) {return file4setLen(this, newLen);}
 | 
						|
   int unlock( long pos_start, long num_bytes )
 | 
						|
                               { return file4unlock (this, pos_start, num_bytes) ; }
 | 
						|
   int write( const long pos, const void S4PTR* ptr, const unsigned len )
 | 
						|
                               { return file4write( this, pos, ptr, len ) ;  }
 | 
						|
   int write( const long pos, const char *nullended )
 | 
						|
                               { return write( pos, nullended, strlen(nullended) ) ; }
 | 
						|
   int write( const long pos, Str4 &s )
 | 
						|
                               { return write( pos, (void *)s.ptr( ), s.len( ) ) ;}
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS File4seqRead : public FILE4SEQ_READ
 | 
						|
{
 | 
						|
public:
 | 
						|
 | 
						|
   File4seqRead( File4 &f, const long start_pos, void *buf, const unsigned buf_len )
 | 
						|
                               { file4seqReadInit( this, &f, start_pos, buf, buf_len ) ;}
 | 
						|
   File4seqRead() {}
 | 
						|
 | 
						|
   File4seqRead& operator>>( Str4 &string) { read(string); return *this;}
 | 
						|
 | 
						|
   void init( File4 &f, long start_pos, void *buf, const unsigned buf_len )
 | 
						|
                               { file4seqReadInit( this, &f, start_pos, buf, buf_len ) ;}
 | 
						|
   unsigned read( void *ptr, const unsigned len )
 | 
						|
                    { return file4seqRead( this, ptr, len ) ; }
 | 
						|
   unsigned read( Str4 &s )
 | 
						|
                    { return file4seqRead( this, s.ptr(), s.len());}
 | 
						|
   int readAll( void *ptr, const unsigned len )
 | 
						|
                    { return file4seqReadAll( this, ptr, len);}
 | 
						|
   int readAll( Str4 &s )
 | 
						|
                    { return file4seqReadAll( this, s.ptr(), s.len());}
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS File4seqWrite : public FILE4SEQ_WRITE
 | 
						|
{
 | 
						|
public:
 | 
						|
   File4seqWrite( File4 &f, const long start_pos, void *buf, const unsigned buf_len )
 | 
						|
                               { file4seqWriteInit( this, &f, start_pos, buf, buf_len ) ; }
 | 
						|
   File4seqWrite() {}
 | 
						|
   File4seqWrite &operator<<( Str4 &buf)
 | 
						|
                               { write( buf ) ; return *this ;}
 | 
						|
   File4seqWrite &operator<<( const long  l) {char t[256];
 | 
						|
                                              c4ltoa45(l, t, 9);
 | 
						|
                                              t[9] = '\0';
 | 
						|
                                              write(t);
 | 
						|
                                              return *this;}
 | 
						|
   File4seqWrite &operator<<( const char *buf )
 | 
						|
                               { write( buf, strlen(buf)); return *this ;}
 | 
						|
 | 
						|
   void init( File4 &f, const long start_pos, void *buf, const unsigned buf_len )
 | 
						|
                               { file4seqWriteInit( this, &f, start_pos, buf, buf_len ) ; }
 | 
						|
   int flush()                 { return file4seqWriteFlush( this ); }
 | 
						|
   int repeat( const long num_repeat, const char ch )
 | 
						|
                               { return file4seqWriteRepeat( this, num_repeat, ch);}
 | 
						|
   int write( const void *info, const unsigned info_len )
 | 
						|
                               { return file4seqWrite( this, info, info_len ) ;}
 | 
						|
   int write( const char *info )
 | 
						|
                               { return file4seqWrite( this, info, strlen(info));}
 | 
						|
   int write( Str4 &s )
 | 
						|
                               { return file4seqWrite( this, s.ptr(), s.len()) ;}
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS List4 : public LIST4
 | 
						|
{
 | 
						|
public:
 | 
						|
   List4()                     { init() ; }
 | 
						|
   List4( List4 &) ;             // illegal operation, force link error
 | 
						|
   operator =( List4 &);         // illegal operation, force link error
 | 
						|
 | 
						|
   void *add( void *item )     { l4add( this, item ) ;return item ;}
 | 
						|
   void *addAfter( void *anchor, void *item )
 | 
						|
                               { l4addAfter( this, anchor, item ) ; return item; }
 | 
						|
   void *addBefore( void *anchor, void *item )
 | 
						|
                               { l4addBefore( this, anchor, item ) ; return item;}
 | 
						|
   void S4PTR*first()          { return l4first( this ) ;}
 | 
						|
   void S4PTR*last()           { return l4last(this) ;}
 | 
						|
   void S4PTR*next( void *item = NULL )
 | 
						|
                               { return l4next( this, item ) ;}
 | 
						|
   int   numNodes()            { return nLink ; }
 | 
						|
   void S4PTR*pop()            { return l4pop( this ) ;}
 | 
						|
   void S4PTR*prev( void *item){ return l4prev( this, item ) ; }
 | 
						|
   void remove( void *item )   { l4remove( this, item ) ; }
 | 
						|
   void init()                { lastNode = 0 ; nLink = 0 ; }
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Sort4 : public SORT4
 | 
						|
{
 | 
						|
public:
 | 
						|
   Sort4() {} ;
 | 
						|
   Sort4( Code4 &code, int sort_len, int other_len = 0 )
 | 
						|
         { sort4init( this, &code, sort_len, other_len ) ;}
 | 
						|
   Sort4( Sort4 &) ;      // Illegal operation, force link error
 | 
						|
   operator =( Sort4&) ;  // Illegal operation, force link error
 | 
						|
   void *result, *resultOther ;
 | 
						|
   long  resultRec ;
 | 
						|
 | 
						|
 //  #ifdef S4WINDOWS
 | 
						|
 //    #ifndef _MSC_VER
 | 
						|
 //   #ifndef STRICT
 | 
						|
 //     void assignCmp(S4CMP_FUNCTION *f) { sort4assignCmp( this, f ) ;}
 | 
						|
 // #endif
 | 
						|
 //#endif
 | 
						|
 //#else
 | 
						|
//   void assignCmp(int *f) { *f=0;}
 | 
						|
     void assignCmp(S4CMP_FUNCTION_PTR f) { sort4assignCmp( this, f ) ;}
 | 
						|
   //{ sort4assignCmp( this, f ) ;}
 | 
						|
 //#endif
 | 
						|
   int free() { return sort4free( this ) ;}
 | 
						|
   int get() { return sort4get( this, &resultRec, (void S4PTR*S4PTR*)&result, (void S4PTR*S4PTR*)&resultOther ) ;}
 | 
						|
   int getInit() { return sort4getInit( this ) ;}
 | 
						|
   int init( Code4 &code, int sort_len, int other_len = 0 )
 | 
						|
         { return sort4init( this, &code, sort_len, other_len ) ;}
 | 
						|
   int put( void *sort_info, void *other_info = NULL, long rec = 0L )
 | 
						|
         { return sort4put( this, rec, sort_info, other_info ) ;}
 | 
						|
 | 
						|
};
 | 
						|
 | 
						|
class S4CLASS Mem4
 | 
						|
{
 | 
						|
public:
 | 
						|
   Mem4() { mem = 0; }
 | 
						|
   Mem4( Code4 &code, int start, int size, int expand, int temp = 1 )
 | 
						|
          { mem = mem4create( &code, start, size, expand, temp ) ;}
 | 
						|
   Mem4( MEM4 S4PTR *m ) { this->mem = m ; }
 | 
						|
   MEM4 S4PTR *mem ;
 | 
						|
   void S4PTR*alloc()  { return mem4alloc( mem ) ;}
 | 
						|
   int  create( Code4 &code, int units_start, int unit_size, int units_expand, int make_temp = 1 )
 | 
						|
          { mem = mem4create( &code, units_start, unit_size, units_expand, make_temp ) ;
 | 
						|
            return (mem==0) ? -1 : 0; }
 | 
						|
   void free( void *ptr ) { mem4free( mem, ptr ) ;}
 | 
						|
   int isValid( ) { return mem!=0 ;}
 | 
						|
   void release() { mem4release(mem) ;}
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Relate4
 | 
						|
{
 | 
						|
public:
 | 
						|
   Relate4() { relate = 0 ; }
 | 
						|
   Relate4( Relate4 master, Data4 slave, char *m_expr, Tag4 t )
 | 
						|
            { relate = relate4createSlave( master.relate, slave.dat(),m_expr, t.tag ) ; }
 | 
						|
   Relate4( RELATE4 S4PTR *r ) { relate = r ; }
 | 
						|
   Data4 data( ) { return (relate) ? Data4((DATA4 *)relate->data) : Data4((DATA4 *)NULL);}
 | 
						|
   Tag4 dataTag( ) { return (relate) ? Tag4((TAG4 *)relate->dataTag) : Tag4((TAG4 *)NULL);}
 | 
						|
   int doOne( )         { return relate4doOne( relate ) ; }
 | 
						|
   int errorAction( int a ) { return relate4errorAction( relate, a ) ; }
 | 
						|
   int init( Relate4 master, Data4 slave, char *m_expr, Tag4 t )
 | 
						|
                    { relate = relate4createSlave( master.relate, slave.dat(), m_expr, t.tag ) ;
 | 
						|
                      return slave.dat()->codeBase->errorCode ; }
 | 
						|
 | 
						|
   int isValid() { return relate != NULL ; }
 | 
						|
 | 
						|
   Relate4 master() { return (relate) ? Relate4((RELATE4 *)relate->master):Relate4((RELATE4 *)NULL) ;}
 | 
						|
 | 
						|
   #ifndef S4CB51
 | 
						|
      const char S4PTR *masterExpr() { return relate4masterExpr(relate) ; }
 | 
						|
   #endif
 | 
						|
 | 
						|
   //Expr4 masterExpr() { return (relate)?Expr4((EXPR4 *)relate->masterExpr):Expr4((EXPR4 *)NULL);}
 | 
						|
 | 
						|
   int matchLen( int p ) { return relate4matchLen( relate, p ) ;}
 | 
						|
   int type( int p )    { return relate4type( relate, p ) ; }
 | 
						|
 | 
						|
   RELATE4 S4PTR *relate ;
 | 
						|
} ;
 | 
						|
 | 
						|
class S4CLASS Relate4iterator : public Relate4
 | 
						|
{
 | 
						|
public:
 | 
						|
  Relate4iterator() {relate=0;}
 | 
						|
  Relate4iterator(class Relate4 r) {relate=r.relate;}
 | 
						|
  int next() {return relate4next(&relate) !=2;}
 | 
						|
  int nextPosition() {return relate4next(&relate);}
 | 
						|
} ;
 | 
						|
 | 
						|
 | 
						|
class S4CLASS Relate4set:public Relate4
 | 
						|
{
 | 
						|
public:
 | 
						|
   Relate4set( Data4 data) { relate = relate4init( data.dat() ) ; }
 | 
						|
   Relate4set()          {relate = 0;}
 | 
						|
   Relate4set( RELATE4 S4PTR *r ) { relate = r ; }
 | 
						|
 | 
						|
   int bottom()              { return relate4bottom( relate ) ; }
 | 
						|
   void changed()            { relate4changed( relate ) ; }
 | 
						|
   int doAll()              { return relate4doAll( relate ) ; }
 | 
						|
   int eof()                 { return relate4eof( relate ) ; }
 | 
						|
   int free( int p = 0 )     { int rc = relate4free( relate, p ) ; relate = 0; return rc; }
 | 
						|
   int init( Data4 data )   { relate = relate4init( data.dat() ) ; return data.dat()->codeBase->errorCode ; }
 | 
						|
   int lockAdd()                { return relate4lockAdd( relate ) ; }
 | 
						|
   #ifndef S4CB51
 | 
						|
      int optimizeable()      { return relate4optimizeable( relate ) ; }
 | 
						|
   #endif
 | 
						|
   int querySet( char *p = NULL )  { return relate4querySet( relate, p ) ; }
 | 
						|
   int skip( long l = 1)     { return relate4skip( relate, l ) ; }
 | 
						|
   int skipEnable( int do_enable = 1 ) { return relate4skipEnable(relate,do_enable);}
 | 
						|
   int sortSet(const char *sort=NULL) {return relate4sortSet(relate, sort);}
 | 
						|
   int top() {return relate4top(relate);}
 | 
						|
} ;
 | 
						|
 | 
						|
 | 
						|
#ifdef S4CLIENT
 | 
						|
inline int Code4::init( void )
 | 
						|
{
 | 
						|
   int rc = code4initLow( this,DEF4PROTOCOL,S4VERSION ) ;
 | 
						|
   _fmemset( string_types, 0, sizeof(string_types) ) ;
 | 
						|
   return rc ;
 | 
						|
}
 | 
						|
#else
 | 
						|
inline int Code4::init( void )
 | 
						|
{
 | 
						|
    int rc = code4initLow( this,0,S4VERSION ) ;
 | 
						|
    _fmemset( string_types, 0, sizeof(string_types) ) ;
 | 
						|
    return rc ;
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
inline Data4 Code4::data( char *alias )
 | 
						|
{
 | 
						|
  Data4 r;
 | 
						|
  r.data=code4data(this,alias);
 | 
						|
  return r;
 | 
						|
}
 | 
						|
 | 
						|
inline int   Data4::openClone( Data4 d )
 | 
						|
{
 | 
						|
   data=d4openClone(d.dat());
 | 
						|
   return data->codeBase->errorCode;
 | 
						|
}
 | 
						|
 | 
						|
inline Expr4::Expr4(Data4 d, char *ex)
 | 
						|
{
 | 
						|
   expr=expr4parse(d.dat(),ex);
 | 
						|
}
 | 
						|
 | 
						|
inline Data4 Expr4::data()const
 | 
						|
{
 | 
						|
   return Data4( expr->data ) ;
 | 
						|
}
 | 
						|
 | 
						|
inline Tag4 Index4::tag( char *name )
 | 
						|
{
 | 
						|
  Tag4 t;
 | 
						|
  t.tag=i4tag(index,name);
 | 
						|
  return t;
 | 
						|
}
 | 
						|
 | 
						|
inline int Index4::create( Data4 d, S4CONST Tag4info& info )
 | 
						|
{
 | 
						|
  index = i4create( d.dat(), 0, info.tag ) ;
 | 
						|
  return d.dat()->codeBase->errorCode ;
 | 
						|
}
 | 
						|
 | 
						|
inline int Expr4::parse( Data4 d, char *ex )
 | 
						|
{
 | 
						|
   #ifdef E4DEBUG
 | 
						|
      if( expr )
 | 
						|
         error4( d.dat()->codeBase, e4info, E60601 ) ;
 | 
						|
   #endif
 | 
						|
   expr = expr4parse( d.dat(), ex ) ;
 | 
						|
   return d.dat()->codeBase->errorCode ;
 | 
						|
}
 | 
						|
 | 
						|
inline Index4 Data4::index( const char *name=NULL )
 | 
						|
{
 | 
						|
   return Index4( d4index(data, name)) ;
 | 
						|
}
 | 
						|
 | 
						|
inline void Data4::select( Tag4 tag )
 | 
						|
{
 | 
						|
   d4tagSelect( data, tag.tag ) ;
 | 
						|
   return;
 | 
						|
}
 | 
						|
 | 
						|
inline void Data4::select( const char *tagName )
 | 
						|
{
 | 
						|
   if( tagName != NULL )
 | 
						|
   {
 | 
						|
      TAG4 *tag = d4tag( data, tagName ) ;
 | 
						|
      d4tagSelect( data, tag ) ;
 | 
						|
      return;
 | 
						|
   }
 | 
						|
   d4tagSelect( data, NULL ) ;
 | 
						|
   return;
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
inline int    Index4::create( Data4 d, S4CONST char *name, S4CONST Tag4info& info )
 | 
						|
  { index = i4create( d.dat(), name, info.tag ) ;
 | 
						|
  return d.dat()->codeBase->errorCode ; }
 | 
						|
 | 
						|
inline int Field4memo::setLen( unsigned new_len )
 | 
						|
{
 | 
						|
   #ifdef S4OFF_MEMO
 | 
						|
      return e4notMemo ;
 | 
						|
   #else
 | 
						|
      #ifdef S4OFF_WRITE
 | 
						|
         return e4notWrite ;
 | 
						|
      #else
 | 
						|
         int rc ;
 | 
						|
         char *buf = 0 ;
 | 
						|
 | 
						|
         if( field->memo == 0 )
 | 
						|
            return -1 ;
 | 
						|
 | 
						|
         if( new_len > field->memo->lenMax )
 | 
						|
         {
 | 
						|
            buf = (char *) u4allocFree( (CODE4 *) field->data->codeBase, new_len ) ;
 | 
						|
            memcpy( buf, field->memo->contents, field->memo->lenMax ) ;
 | 
						|
         }
 | 
						|
         rc = f4memoSetLen(field,new_len) ;
 | 
						|
         if( buf != 0 )
 | 
						|
         {
 | 
						|
            memcpy( field->memo->contents, buf, field->memo->lenMax ) ;
 | 
						|
            u4free( buf ) ;
 | 
						|
         }
 | 
						|
         return rc ;
 | 
						|
      #endif
 | 
						|
   #endif
 | 
						|
}
 | 
						|
 | 
						|
#ifndef S4OFF_REPORT
 | 
						|
REPORT4 * S4FUNCTION  report4retrieve(Code4 &cb, char *file_name,
 | 
						|
                      int open_files, char *pathname);
 | 
						|
RELATE4 * S4FUNCTION relate4retrieve( Code4 &cb, char *file_name,
 | 
						|
                      int open_files, char *pathname);
 | 
						|
int S4FUNCTION relate4save(Relate4set &relSet, char *file_name,
 | 
						|
                      int save_paths);
 | 
						|
#endif /* NOT S4OFF_REPORT */
 | 
						|
#endif /* __DATA4HEADER */
 | 
						|
 |