home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / VFORM.ZIP / Samples / vfTest / Person.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-10  |  2.0 KB  |  60 lines

  1. // -------------------------------------------------------------------------
  2. // Copyright @ 1997 TCK Software, Incorporated
  3. // All Rights Reserved
  4. // -------------------------------------------------------------------------
  5. #ifndef __PERSON_H__
  6. #define __PERSON_H__
  7.  
  8. #include <string.h>
  9. #include "recDb.h"
  10.  
  11. // -------------------------------------------------------------------------
  12. // This file contains the class definintions of the Person Book and contained 
  13. // objects
  14. //    CPersonDB   - the person flat file database - a parameterized CRecDB
  15. //                    represents a person database (flat file DB of CPerson records)
  16. //                    the file contains 1 heading line and many Person Objects
  17. //    CPerson        - the person structure
  18. //                    represents a single person record
  19. //    CRecDB        - a record database object - a Parameterized (Template) Class
  20. //                    represents a flat file database of records
  21. //                    the file contains 0 to many T Objects
  22. // -------------------------------------------------------------------------
  23.  
  24. #define PERS_NAME    30
  25. #define PERS_ADDR    30
  26. #define PERS_CITY    30
  27. #define PERS_STATE    2
  28. #define PERS_ZIP    5
  29. #define PERS_PHONE    15
  30.  
  31. struct CPerson
  32. {
  33.     _TCHAR    m_name[PERS_NAME+1];        // Name
  34.     _TCHAR    m_address[PERS_ADDR+1];        // Adddress
  35.     _TCHAR    m_city[PERS_CITY+1];        // City
  36.     _TCHAR    m_state[PERS_STATE+1];        // State
  37.     _TCHAR    m_zip[PERS_ZIP+1];            // Zip Code
  38.     _TCHAR    m_phone[PERS_PHONE+1];        // Phone
  39.     _TCHAR    m_bFriend;                    // Y or N
  40.     _TCHAR    m_deleted;                    // Y or N
  41.     _TCHAR    m_carriage_return;
  42.     _TCHAR    m_newline;
  43.  
  44. public:
  45.     CPerson();                                    // Constructor
  46.     CPerson(CPerson &);                        // Copy Constructor 
  47.     ~CPerson();                                // Destructor
  48.     CPerson& operator =(CPerson &);            // Copy operator
  49.     BOOL    IsDeleted() { return (m_deleted == _T('Y')); }
  50.     void    OnWrite()    
  51.         { RecDB_Replace((_TCHAR*)this, sizeof(*this), _T('\0'), _T('~')); }
  52.     void    OnRead()    
  53.         { RecDB_Replace((_TCHAR*)this, sizeof(*this), _T('~'), _T('\0')); }
  54.     void Clear();
  55. };
  56.  
  57.  
  58. typedef CRecDB<CPerson> CPersonDB;
  59.  
  60. #endif