home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual dBase v5.5 / EXTERN.PAK / DBFILE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-18  |  3.0 KB  |  97 lines

  1. //****************************************************************************
  2. //
  3. // FILE:        DBFile.h
  4. //
  5. // WRITTEN BY:  Keimpe
  6. //
  7. // DATE:        1/94
  8. //
  9. // UPDATED:     5/95
  10. //
  11. // REVISION:    $Revision:   2.10  $
  12. //
  13. // VERSION:     Visual dBASE
  14. //
  15. // DESCRIPTION:
  16. //
  17. //              TextFile header file that describes the TextFile class.
  18. //              Part of dbfile, a Visual dBASE example.
  19. //              See dbfile.cpp for a description of the example.
  20. //
  21. //****************************************************************************
  22.  
  23. #ifndef DBFILE_H
  24.  
  25.    // Get the DBaseVar and DVar stuff.
  26. #include "dbasevar.h"
  27.  
  28.    // C++ TextFile Class.
  29. class TextFile {
  30.  
  31. private:
  32.  
  33.    // BUFFERLENGTH indicates how many char's are read in at the same
  34.    // time with a call to read.
  35. #define BUFFERLENGTH 16000
  36.  
  37.    char         Buffer[ BUFFERLENGTH + 1 ]; // Holds a buffer of text.
  38.    char        *BufPtr;              // Points into the Buffer..
  39.    char        *CopyPtr;             // Start of Bufferpart to copy.
  40.    char         ErrorString[50];     // Room for errormessages.
  41.    char         FieldSeparator;      // Field separator char.
  42.    char        *Filter;              // Holds the filter.
  43.    long         FilterLen;           // How long is the filter.
  44.    int          Handle;              // To hold the filehandle.
  45.    char         LineSeparator;       // Line separator char.
  46.    unsigned int MaxTextLen;          // Maximum length of Text.
  47.    int          NumberOfFields;      // # of fields in a rec.
  48.    char         PlusLineSeparator;   // Do we want any number of this one.
  49.    char        *SaveFieldEndPtr;     // Marks the end of a field in Text.
  50.    char        *Text;                // Text send over to Visual dBASE.
  51.    unsigned int TextLen;             // Length of Text.
  52.  
  53. public:
  54.       // Default constructor.
  55.    TextFile() {
  56.        Handle = 0;
  57.        Text = new char[2];           // Room for a fieldseparator.
  58.        Text[0] = 0x0;
  59.        Text[1] = 0;
  60.        TextLen = 0;
  61.        MaxTextLen = 1;
  62.        Filter = new char[1];
  63.        Filter[0] = 0x0;
  64.        FilterLen = 0;
  65.        FieldSeparator = ' ';
  66.        LineSeparator = '\n';
  67.        PlusLineSeparator = 0;        // Default is one EOL.
  68.    }
  69.  
  70.       // Destructor
  71.    ~TextFile() {
  72.       if( Handle != 0 )
  73.          close( Handle );
  74.       delete [] Text;
  75.       delete [] Filter;
  76.    }
  77.  
  78.       // Routines.
  79.    BOOL  AddToText( char *, char * );
  80.    BOOL  Close();
  81.    BOOL  Eof()                         { return *BufPtr == 0x0 &&
  82.                                                 eof( Handle ); }
  83.    BOOL  Error()                       { return ErrorString[0] != 0x0; }
  84.    char *GetErrorString()              { return ErrorString; }
  85.    char *GetField( int );
  86.    int   GetNumberOfFields()           { return NumberOfFields; }
  87.    BOOL  Open( char *FileToOpen );
  88.    char *ReadNextItem( char );
  89.    BOOL  SetFieldSeparator( char * );
  90.    BOOL  SetFilter( char * );
  91.    BOOL  SetLineSeparator( char * );
  92. };
  93.  
  94. #define DBFILE_H
  95. #endif
  96.  
  97.