dbtable.h

Go to the documentation of this file.
00001 /**
00002  * \file rvc/dbtable.h
00003  * \brief interface for the RVC::DBTABLE class.
00004  *
00005  * \if NODOC
00006  * $Id: dbtable.h_v 1.109 2004/10/06 19:52:42 dfriberg Exp $
00007  *
00008  * $Log: dbtable.h_v $
00009  * Revision 1.109  2004/10/06 19:52:42  dfriberg
00010  * Added DBTABLE::Combine method (uses MfTableCombine)
00011  *
00012  * Revision 1.108  2004/09/10 17:06:16  mju
00013  * Add typedef for STYLE_MULTI for future renaming of classes so not specific to cad.
00014  *
00015  * Revision 1.107  2004/06/03 18:06:35  scowan
00016  * Added break's for inline switch statements.
00017  *
00018  * Revision 1.106  2004/05/27 17:56:56  scowan
00019  * Added inline methods for cad style assign table.
00020  *
00021  * Revision 1.105  2004/03/04 18:44:05  scowan
00022  * Added virtual dtor to filter class.
00023  *
00024  * Revision 1.104  2004/02/18 23:02:34  scowan
00025  * Added clear method to fieldinfo.
00026  *
00027  * Revision 1.103  2003/12/03 21:27:53  scowan
00028  * Added methods to compare structures of two tables.
00029  *
00030  * Revision 1.102  2003/10/17 14:56:26  scowan
00031  * Added another open method.
00032  *
00033  * Revision 1.101  2003/10/16 13:45:25  scowan
00034  * Fixed g++ complaint.
00035  *
00036  * Revision 1.100  2003/10/15 19:32:45  scowan
00037  * Added another get object filter for tables.
00038  *
00039  * Revision 1.99  2003/10/07 17:34:27  scowan
00040  * Object virtual method changes.
00041  *
00042  * Revision 1.98  2003/10/06 21:39:18  scowan
00043  * Added method to invalidate a node turn entry.
00044  *
00045  * Revision 1.97  2003/10/01 21:45:46  scowan
00046  * Added node turn table definition.
00047  *
00048  * Revision 1.96  2003/09/30 16:52:06  dwilliss
00049  * Doxygen
00050  *
00051  * Revision 1.95  2003/09/25 21:20:04  dwilliss
00052  * Fixed doxygen comment
00053  *
00054  * Revision 1.94  2003/09/19 22:25:59  scowan
00055  * Moved get name and get desc to virtual methods.
00056  *
00057  * Revision 1.93  2003/09/15 13:49:45  fileserver!dwilliss
00058  * Doxygen
00059  *
00060  * Revision 1.92  2003/08/20 16:10:02  scowan
00061  * nc.
00062  *
00063  * Revision 1.91  2003/06/25 22:17:57  scowan
00064  * oops.
00065  *
00066  * Revision 1.90  2003/06/25 22:16:45  scowan
00067  * Added oracle stuff.
00068  *
00069  * Revision 1.89  2003/05/21 22:01:23  msmith
00070  * Added reference to original record for Extruded Points
00071  * and Influence Sphere.
00072  *
00073  * Revision 1.88  2003/05/02 21:25:00  scowan
00074  * Added methods to style cad class.
00075  *
00076  * Revision 1.87  2003/04/09 20:15:33  dwilliss
00077  * Don't use _T in templates. Mac's ctype.h defines global _T. Thanks Apple!
00078  *
00079  * Revision 1.86  2003/03/10 18:08:06  mju
00080  * Add FIELDINFO::FLAG_None and spell out other flag values.
00081  *
00082  * Revision 1.85  2003/01/22 17:01:18  scowan
00083  * Added method to get the index for a field.
00084  *
00085  * Revision 1.84  2002/12/16 17:53:57  scowan
00086  * Added binary field handling code to the record class.
00087  *
00088  * Revision 1.83  2002/12/03 17:06:41  scowan
00089  * Added more comments.
00090  *
00091  * Revision 1.82  2002/10/18 22:06:23  vdronov
00092  * modifyed extruded points design
00093  *
00094  * Revision 1.81  2002/10/17 22:23:16  vdronov
00095  * added INFLUENCE_SPHERE
00096  *
00097  * Revision 1.80  2002/10/03 22:09:29  mju
00098  * Make ctor public in makeparm for style_element.
00099  *
00100  * Revision 1.79  2002/09/05 20:53:13  vdronov
00101  * changed EXTRUDED_POINTS and PARAMETERS_SELECT
00102  *
00103  * Revision 1.78  2002/08/28 14:15:40  scowan
00104  * nc.
00105  *
00106  * Revision 1.77  2002/08/21 20:39:04  scowan
00107  * Deprecate old object name define.
00108  *
00109  * Revision 1.76  2002/08/19 15:13:28  scowan
00110  * Fixed g++ 3.1 warnings.
00111  *
00112  * Revision 1.75  2002/08/13 21:37:18  scowan
00113  * Moved database include file.
00114  *
00115  * Revision 1.74  2002/04/22 17:52:56  scowan
00116  * Added twin open method.
00117  *
00118  * Revision 1.73  2002/04/18 16:29:11  scowan
00119  * Added open using database id methods.
00120  *
00121  * Revision 1.72  2002/04/15 17:01:45  scowan
00122  * Add methods for record table and record numbers.
00123  *
00124  * Revision 1.71  2002/04/12 14:14:44  scowan
00125  * Include enum defines for select and style mode.
00126  *
00127  * Revision 1.51  2002/03/13 21:36:34  vdronov
00128  * added get/set methods for flightpath and pointofinterest
00129  *
00130  * Revision 1.50  2002/03/08 23:02:14  vdronov
00131  * added records for flightpath and pointofinterest
00132  *
00133  * Revision 1.49  2002/03/08 22:34:50  vdronov
00134  * added makeparms for flightpath and pointofinterest
00135  *
00136  * Revision 1.48  2002/03/08 17:49:57  dwilliss
00137  * added USAGEs for flight paths
00138  *
00139  * Revision 1.47  2002/02/18 18:46:07  scowan
00140  * Added template makeparm constructor.
00141  *
00142  * Revision 1.46  2002/02/18 18:11:50  scowan
00143  * Remove assignment and copy from iterators.
00144  *
00145  * Revision 1.45  2002/02/18 16:22:02  scowan
00146  * Fix cursor problems.
00147  *
00148  * Revision 1.44  2002/02/15 21:40:56  scowan
00149  * Fixed operator ==.
00150  *
00151  * Revision 1.43  2002/02/15 20:14:12  scowan
00152  * Added more methods.
00153  *
00154  * Revision 1.42  2002/02/14 23:28:12  scowan
00155  * Updated inheritance to fully qualified named for genator docs.
00156  *
00157  * Revision 1.41  2002/02/14 21:58:50  scowan
00158  * Added a methof for field info.
00159  *
00160  * Revision 1.40  2002/02/14 21:08:12  scowan
00161  * Added flag.
00162  *
00163  * Revision 1.39  2002/02/14 21:04:54  scowan
00164  * Doc update.
00165  *
00166  * Revision 1.38  2002/02/14 17:42:07  scowan
00167  * Nothing.
00168  *
00169  * Revision 1.37  2002/02/14 17:17:40  scowan
00170  * Removed relation get methods.
00171  * Added choice for related field for special table creation.
00172  *
00173  * Revision 1.36  2002/02/14 16:37:08  scowan
00174  * Added record number from iterator method.
00175  *
00176  * Revision 1.35  2002/02/14 15:09:37  scowan
00177  * More small changes.
00178  *
00179  * Revision 1.34  2002/02/14 00:00:55  scowan
00180  * Yet more changes.
00181  *
00182  * Revision 1.33  2002/02/13 22:58:02  scowan
00183  * More suggested changes done.
00184  *
00185  * Revision 1.32  2002/02/13 20:55:10  scowan
00186  * Many changes and class renaming.
00187  *
00188  * Revision 1.31  2002/02/13 15:57:43  scowan
00189  * Renamed specialty record classes.
00190  *
00191  * Revision 1.30  2002/02/11 20:29:44  scowan
00192  * Moved many classes to be documented.
00193  *
00194  * Revision 1.29  2002/01/30 00:09:25  scowan
00195  * Chagned FindRecords methods to not take a void pointer.
00196  *
00197  * Revision 1.28  2002/01/02 17:13:03  scowan
00198  * Nothing.
00199  *
00200  * Revision 1.27  2001/09/20 15:26:03  scowan
00201  * Added enum values for DateTime field type.
00202  *
00203  * Revision 1.26  2001/09/18 21:35:57  scowan
00204  * Fixed record iterators.
00205  *
00206  * Revision 1.25  2001/09/07 22:00:54  scowan
00207  * Record class now keeps track of table closings.
00208  *
00209  * Revision 1.24  2001/07/25 22:16:34  scowan
00210  * n/c.
00211  *
00212  * Revision 1.23  2001/07/19 19:11:03  scowan
00213  * Add support for creating linked tables.
00214  *
00215  * Revision 1.22  2001/06/20 21:04:29  scowan
00216  * Clean up more constraints.
00217  *
00218  * Revision 1.21  2001/06/20 17:10:43  scowan
00219  * Removed unused items in the constraint wrapper.
00220  *
00221  * Revision 1.20  2001/06/20 16:08:22  scowan
00222  * Added constraint class and read and write methods.
00223  *
00224  * Revision 1.19  2001/06/19 17:32:12  scowan
00225  * Added method to determine table prompt set.
00226  *
00227  * Revision 1.18  2001/06/14 17:42:03  scowan
00228  * Added to RVC namespace.
00229  *
00230  * Revision 1.17  2001/06/11 16:13:44  scowan
00231  * Fixed warnings.
00232  *
00233  * Revision 1.15  2001/06/11 16:04:15  scowan
00234  * Changed field type Time to DateTime.
00235  *
00236  * Revision 1.14  2001/06/07 15:48:02  scowan
00237  * New constructor for element id record.
00238  *
00239  * Revision 1.13  2001/06/07 15:45:34  scowan
00240  * Added non-=moving field info update method.
00241  *
00242  * Revision 1.12  2001/06/06 21:46:08  scowan
00243  * Record write method const sting.
00244  *
00245  * Revision 1.11  2001/06/06 20:59:41  scowan
00246  * Added time field type and edit log table usage field.
00247  *
00248  * Revision 1.10  2001/05/31 21:49:51  scowan
00249  * Added invalid field type.
00250  *
00251  * Revision 1.9  2001/05/31 19:36:35  scowan
00252  * Added a method to clear a record.
00253  *
00254  * Revision 1.8  2001/05/29 21:51:43  scowan
00255  * Added method ishidden.
00256  *
00257  * Revision 1.7  2001/05/25 17:07:27  scowan
00258  * Initialize record method.
00259  *
00260  * Revision 1.6  2001/05/25 16:46:12  scowan
00261  * More comments.
00262  *
00263  * Revision 1.5  2001/05/25 15:04:27  scowan
00264  * Stupid G++ error.
00265  *
00266  * Revision 1.4  2001/05/24 14:53:37  scowan
00267  * Fixed UNIX MAC errors.
00268  *
00269  * Revision 1.3  2001/05/23 22:43:40  scowan
00270  * Used ERRORPOSNDIABLE class in appropriate places.
00271  *
00272  * Revision 1.2  2001/05/23 21:55:08  scowan
00273  * Finished wrapper for now.
00274  *
00275  * Revision 1.1  2001/05/23 20:24:54  scowan
00276  * Initial revision
00277  *
00278  * \endif
00279 **/
00280 
00281 //!
00282 //!   \class RVC::DBTABLE rvc/dbtable.h
00283 //!   \brief Manages RVC::OBJTYPE_Table objects.  
00284 //!
00285 //!   The RVC::DBTABLE class manages RVC::OBJTYPE_Table objects.  The interface currently wraps the MfDatabaseTable functions.
00286 //!
00287 //!   RVC Object Types that this class supports: RVC::OBJTYPE_Table.
00288 //!
00289 //!   Default RVC Object Type for this class: RVC::OBJTYPE_Table.
00290 //!
00291 //!   Valid parents for this class:
00292 //!      - RVC::OBJTYPE_Database
00293 //!      - RVC::OBJTYPE_Database_Raster
00294 //!      - RVC::OBJTYPE_Database_VectorPoint
00295 //!      - RVC::OBJTYPE_Database_VectorLine
00296 //!      - RVC::OBJTYPE_Database_VectorPolygon
00297 //!      - RVC::OBJTYPE_Database_CAD
00298 //!      - RVC::OBJTYPE_Database_TIN
00299 //!      - RVC::OBJTYPE_Database_Shape
00300 //!
00301 
00302 #ifndef INC_RVC_DBTABLE_H
00303 #define INC_RVC_DBTABLE_H
00304 
00305 #ifndef INC_RVC_DBASE_H
00306    #include <rvc/dbase.h>
00307 #endif
00308 
00309 #ifndef INC_RVC_STYLE_H
00310    #include <rvc/style.h>
00311 #endif
00312 
00313 #ifndef INC_MI32_UNITCONV_H
00314    #include <mi32/unitconv.h>
00315 #endif
00316 
00317 #ifndef INC_MI32_BITSET_H
00318    #include <mi32/bitset.h>
00319 #endif
00320 
00321 #ifndef INC_MI32_RANGE_H
00322    #include <mi32/range.h>
00323 #endif
00324 
00325 #ifndef INC_MI32_TEXTID_H
00326    #include <mi32/textid.h>
00327 #endif
00328 
00329 #ifndef  INC_MI32_GREMODE_H
00330    #include <mi32/gremode.h>
00331 #endif
00332 
00333 #include <vector>
00334 
00335 namespace RVC {
00336 
00337 #ifndef GENERATING_DOXYGEN_OUTPUT
00338 class STYLE;         // Forward Declarations
00339 class DBASE_ELEMENT;
00340 #endif // GENERATING_DOXYGEN_OUTPUT
00341 
00342 class DBTABLE : public RVC::OBJECT {
00343    public:
00344 
00345       //! Database table attachment type 
00346       enum ATTACHMENT {
00347          ATTACHMENT_Unknown = 0,          //!< Your standard free-for-all
00348          ATTACHMENT_OneRecordPerElement,  //!< But may use record for multiple elements
00349          ATTACHMENT_OneElementPerRecord,  //!< But element may have multiple records
00350          ATTACHMENT_OneToOne,             //!< At most one record per element and one element per record
00351          ATTACHMENT_RelatedOnly,          //!< No attachments at all, only related
00352          ATTACHMENT_Identity,             //!< Record number is element number
00353          ATTACHMENT_NoRestrictions        //!< Your standard attached to element free-for-all
00354          };
00355          
00356       //! Flags for finding attached record methods (i.e. RVCDBTABLE::GetAttachedRecords())
00357       enum FINDFLAG {
00358          FINDFLAG_AllAttached = 0,
00359          FINDFLAG_OnlyDirect = 2,
00360          FINDFLAG_FirstMatch = 8
00361          };
00362 
00363       //! Flags for searching on an index methods (i.e. RVCDBTABLE::SearchIndex())
00364       enum INDEXSEARCH {
00365          INDEXSEARCH_ReturnIndexOffset =  0x00000000,
00366          INDEXSEARCH_CheckExists =        0x00000001,
00367          INDEXSEARCH_ReturnRecordNumber = 0x00000002,
00368          INDEXSEARCH_ReturnInsertOffset = 0x00000004  
00369          };
00370          
00371       enum ITERATERECORD {
00372          ITERATERECORD_None =          0x0000,
00373          ITERATERECORD_SkipDeleted =   0x0001,
00374          ITERATERECORD_Sort =          0x0002,
00375          ITERATERECORD_UniqueOnly =    0x0004,
00376          ITERATERECORD_SaveIndex =     0x0008,
00377          ITERATERECORD_SingleKey =     0x8000
00378          };
00379          
00380       //! Type of external table
00381       enum LINKTYPE {
00382          LINKTYPE_Internal = 0,  //!< TNTmips internal format
00383          LINKTYPE_MIPS,          //!< MIPS external format (old RVF style) 
00384          LINKTYPE_DBASE3,        //!< dBase III+ format (external only)
00385          LINKTYPE_INFO,          //!< INFO format (external only)
00386          LINKTYPE_DBASE4,        //!< dBase IV (external only)
00387          LINKTYPE_RBASE,         //!< R:BASE (external only)
00388          LINKTYPE_DBASE2,        //!< Dbase 2 (external only)
00389          LINKTYPE_ODBC,          //!< Link to ODBC server (external only)
00390          LINKTYPE_CSV,           //!< Comma Seperated values (export only)
00391          LINKTYPE_TAB,           //!< MapInfo TAB files
00392          LINKTYPE_ORACLE         //!< Oracle server
00393          };
00394 
00395       //! Flags for element referenced tables  (TIN is the only one so far)
00396       enum REFELEM {
00397          REFELEM_All       = 0x00000000,
00398          REFELEM_Node      = 0x00000010,
00399          REFELEM_Edge      = 0x00000020,
00400          REFELEM_Triangle  = 0x00000040,
00401          REFELEM_Hull      = 0x00000080   
00402          };
00403          
00404       //! Result values for CompareStructures() method
00405       enum STRUCTCOMPARE {
00406          STRUCTCOMPARE_DoNotMatch = 0,    //!< Table structures do not match
00407          STRUCTCOMPARE_Exact,             //!< Table structures match exactly
00408          STRUCTCOMPARE_Compatible,        //!< Table structures are compatible, record fields can be converted without loss of data
00409          STRUCTCOMPARE_SameTable          //!< Both tables point to the same linked table
00410          };
00411       
00412       //! Table capability flags, returned by RVCDBTABLE::GetCapability()
00413       enum TABLECAP {
00414          TABLECAP_None =            0x00000000,
00415          TABLECAP_CanCreate =       0x00000001,
00416          TABLECAP_CanLink =         0x00000002,
00417          TABLECAP_ReadMemo =        0x00000004,
00418          TABLECAP_WriteMemo =       0x00000008,
00419          TABLECAP_WriteRecord =     0x00000010,    //!< Can written via API, regardless of TABLECAP_UserWritable
00420          TABLECAP_MultiTable =      0x00000020,
00421          TABLECAP_Server =          0x00000040,
00422          TABLECAP_Import =          0x00000080,
00423          TABLECAP_Export =          0x00000100,
00424          TABLECAP_DeleteRecord =    0x00000200,
00425          TABLECAP_UserWritable =    0x00000400,    //!< ! TABLE_ReadOnly (Only used by editor)
00426          TABLECAP_CanSetUserWrite = 0x00000800,    //!< User can toggle TABLE_ReadOnly
00427          TABLECAP_ChangeFields =    0x00001000,
00428          TABLECAP_AddFields =       0x00002000,
00429          TABLECAP_DeleteFields =    0x00004000,
00430          TABLECAP_AddRecord =       0x00008000,
00431          TABLECAP_RandomAccess =    0x00010000,
00432          TABLECAP_ReadBinary =      0x00020000,
00433          TABLECAP_WriteBinary =     0x00040000
00434          };
00435          
00436       //! Table usage, defines specialized tables
00437       enum USAGE {
00438          USAGE_UserDefined = 0,
00439          USAGE_StdStats = 2,
00440          USAGE_ElementID = 3,
00441          USAGE_NodeTurn = 4,
00442          USAGE_ScaleSelect = 5,
00443          USAGE_Section = 6,
00444          USAGE_Internal = 7,
00445          USAGE_PointStyle = 8,
00446          USAGE_LineStyle = 9,
00447          USAGE_PolyStyle = 10,
00448          USAGE_MultiStyle = 12,
00449          USAGE_CADStyle = USAGE_MultiStyle,
00450          USAGE_EditLog = 13,
00451          USAGE_Selection = 14,
00452          USAGE_FlightPath = 15,
00453          USAGE_PointOfInterest = 16,
00454          USAGE_LegendElement = 17,
00455          USAGE_StyleParameters = 18,
00456          USAGE_SelectParameters = 19,
00457          USAGE_ExtrudedPoints = 20,
00458          USAGE_InfluenceSphere = 21
00459          };
00460 
00461       #ifndef GENERATING_DOXYGEN_OUTPUT
00462       class BOOKMARK;
00463       class CURSOR;
00464       class FIELDINFO;
00465       class GETOBJFILTER_ISUSERDEFINED;
00466       class RECORD;
00467       friend class RECORD;
00468       class RECORD_EXTRUDED_POINTS;
00469       class RECORD_FLIGHTPATH;
00470       class RECORD_ID_ELEMENT;
00471       class RECORD_ID_POINT;
00472       class RECORD_INFLUENCE_SPHERE;
00473       class RECORD_LEGENDELEMENT;
00474       class RECORD_NODETURN;
00475       class RECORD_PARAMETERS_SELECT;
00476       class RECORD_PARAMETERS_STYLE;
00477       class RECORD_POINTOFINTEREST;
00478       class RECORD_SCALESELECT;
00479       class RECORD_SELECTION;
00480       class RECORD_STYLE_CAD;
00481       typedef RECORD_STYLE_CAD RECORD_STYLE_MULTI;
00482       class RECORD_STYLE_ELEMENT;
00483       #endif // GENERATING_DOXYGEN_OUTPUT
00484       
00485       typedef SIMPLE_ARRAY<FIELDINFO> FIELDINFOARRAY;
00486       #ifndef GENERATING_DOXYGEN_OUTPUT
00487       class CONSTRAINT;
00488       class LINKPARMS;
00489       class LINKPARM_CSV;
00490       class LINKPARM_DBASE2;
00491       class LINKPARM_DBASE3;
00492       class LINKPARM_DBASE4;
00493       class LINKPARM_INFO;
00494       class LINKPARM_MIPS;
00495       class LINKPARM_ODBC;
00496       class LINKPARM_ORACLE;
00497       class LINKPARM_RBASE;
00498       class MAKEPARMS;
00499       class MAKEPARM_ID_ELEMENT;
00500       class MAKEPARM_ID_POINT;
00501       class MAKEPARM_STYLE_ELEMENT;
00502       class MAKEPARM_STYLE_CAD;
00503       typedef MAKEPARM_STYLE_CAD MAKEPARM_STYLE_MULTI;
00504       class MAKEPARM_STYLE_LINE;
00505       class MAKEPARM_STYLE_POINT;
00506       class MAKEPARM_STYLE_POLYGON;
00507       class MAKEPARM_SCALESELECT;
00508       class MAKEPARM_SELECTION;
00509       class MAKEPARM_FLIGHTPATH;
00510       class MAKEPARM_POINTOFINTEREST;
00511       class MAKEPARM_LEGENDELEMENT;
00512       class MAKEPARM_NODETURN;
00513       class MAKEPARM_PARAMETERS_STYLE;
00514       class MAKEPARM_PARAMETERS_SELECT;
00515       class MAKEPARM_EXTRUDED_POINTS;
00516       class MAKEPARM_INFLUENCE_SPHERE;
00517       class RECORDITERATOR;
00518       class CONST_RECORDITERATOR;
00519       class OBSERVER;
00520       #endif // GENERATING_DOXYGEN_OUTPUT
00521       
00522       //! Default constructor
00523       DBTABLE (
00524          );
00525 
00526       //! Copy constructor
00527       DBTABLE (                        //! Copy Constructor
00528          const RVC::DBTABLE& rhs
00529          );
00530 
00531       //! Destructor
00532       virtual ~DBTABLE (
00533          );
00534 
00535       //! Assignment
00536       RVC::DBTABLE& operator= (
00537          const RVC::DBTABLE& rhs
00538          );
00539 
00540       //! Add a record to the table
00541       //! @return Record number for the new record
00542       INT32 AddRecord (
00543          RECORD& Record
00544          );
00545 
00546       //! Combine rhs table with this table
00547       ERRVALUE RVC::DBTABLE::Combine (
00548          const RVC::DBTABLE& rhs,
00549          const RVC::DBASE::JOINFLAGS flags,
00550          const RVC::DBASE& dest,          //!< Database in which to store table
00551          const MISTRING& name,            //!< Output table name
00552          const MISTRING& desc             //!< Output table description
00553          );
00554 
00555       //! Compare two table structures
00556       //! @return STRUCTCOMPARE enum value describing if and how the table structures match
00557       STRUCTCOMPARE CompareStructures (
00558          const RVC::DBTABLE& rhs
00559          ) const;
00560          
00561       //! Drop a table (delete)
00562       ERRVALUE Drop (
00563          bool CleanDBList                 //!< Remove the entries in the DBlist that refer to this table
00564          );
00565 
00566       //! Delete a record from the table using the record number
00567       ERRVALUE DeleteRecord (
00568          INT32 RecordNum
00569          );
00570 
00571       //! Delete a record from the table using the cursor and a bookmark
00572       ERRVALUE DeleteRecord (
00573          CURSOR& cursor,
00574          const BOOKMARK& bookmark
00575          );
00576 
00577       //! Find the field cooresponding to the name
00578       //! @return Field number of >= 0, R_FieldNotFound if field does not exist, < 0 Error code
00579       INT32 FindField (
00580          const RVC::OBJECTNAME& name
00581          ) const;
00582          
00583       //! Find the records that match the record data for a given field
00584       //! @return Number of records found or <0 if error 
00585       INT32 FindRecords (
00586          INT32 FieldNum,
00587          double value,                       //!< Buffer containing value to compare to
00588          SIMPLE_ARRAY<INT32>& FoundRecList
00589          ) const;
00590          
00591       //! Find the records that match the record data for a given field
00592       //! @return Number of records found or <0 if error 
00593       INT32 FindRecords (
00594          INT32 FieldNum,
00595          const char* string,              //!< Buffer containing string to compare to
00596          SIMPLE_ARRAY<INT32>& FoundRecList
00597          ) const;
00598          
00599       //! Find the records that match the record data for a given field
00600       //! @return Number of records found or <0 if error 
00601       INT32 FindRecords (
00602          INT32 FieldNum,
00603          const UNICODE* string,              //!< Buffer containing string to compare to
00604          SIMPLE_ARRAY<INT32>& FoundRecList
00605          ) const;
00606          
00607       //! Find the records that match the record data for a given field
00608       //! @return Number of records found or <0 if error 
00609       INT32 FindRecords (
00610          INT32 FieldNum,
00611          const MISTRING& string,             //!< Buffer containing string to compare to
00612          SIMPLE_ARRAY<INT32>& FoundRecList
00613          ) const;
00614          
00615       //! Find the records that match the record data for a given field
00616       //! @return Number of records found or <0 if error 
00617       INT32 FindRecords (
00618          INT32 FieldNum,
00619          const RECORD& record,               //!< Record containing stuff to compare to
00620          SIMPLE_ARRAY<INT32>& FoundRecList,
00621          INT32 RecordFieldNum = -1           //!< Record field number to use, default is 'FieldNum'
00622          ) const;
00623          
00624       //! Get the records attached to the element for this table
00625       //! @return Number of records attached or <0 if error 
00626       INT32 GetAttachedRecords (
00627          INT32 ElementNum,
00628          ELEMTYPE ElemType,
00629          SIMPLE_ARRAY<INT32>& RecordList,
00630          FINDFLAG FindFlags = FINDFLAG_AllAttached
00631          ) const;
00632 
00633       //! Get table attachment type
00634       //! @return Table attachment type
00635       ATTACHMENT GetAttachmentType (
00636          ) const;
00637 
00638       //! Get table capability
00639       //! @return Table capability
00640       TABLECAP GetCapability (
00641          ) const;
00642 
00643       //! Get the computed field query for a field
00644       ERRVALUE GetComputedFieldQuery (
00645          INT32 FieldNum, 
00646          MISTRING& QueryStr
00647          ) const;
00648 
00649       //! Get table encoding
00650       //! @return Table encoding
00651       CHAR_ENCODING GetEncoding (
00652          ) const;
00653          
00654       //! Get the index for a field, will build one if needed
00655       ERRVALUE GetFieldIndex (
00656          INT32 FieldNum,
00657          SIMPLE_ARRAY<INT32>& Index,            //!< List of record numbers in sorted order
00658          BITSET& DuplicateBits                  //!< Bit set to true if value in the record for that field is equal to the previous record
00659          );
00660 
00661       //! Get the FIELDINFO for a single field
00662       ERRVALUE GetFieldInfo (
00663          INT32 FieldNum,
00664          FIELDINFO& FieldInfo
00665          ) const;
00666 
00667       //! Get the FIELDINFO's for the table
00668       ERRVALUE GetFieldInfo (
00669          FIELDINFOARRAY& FieldArray
00670          ) const;
00671 
00672       //! Get the list of fields linked to the starting field     
00673       ERRVALUE GetLinkFields (
00674          INT32 StartFieldNum,                      //!< Field to start checking on
00675          SIMPLE_ARRAY<INT32>& FieldNumArray        //!< One item 'StartFieldNum' if no next_key links, > 1 items if next_key links exists
00676          ) const;     
00677 
00678       //! Get the number of field in the table
00679       //! @return Number of fields
00680       INT32 GetNumFields (
00681          ) const;
00682 
00683       //! Get the number of field in the table
00684       //! @return Number of fields
00685       INT32 GetNumRecords (
00686          ) const;
00687 
00688       //! Get reference element (This table belongs to what element?)
00689       //! @return Reference flags
00690       REFELEM GetReferenceElement (
00691          ) const;
00692          
00693       //! Get the records from this table attached to the record in the basetable
00694       //! @return Number of records attached or <0 if error 
00695       INT32 GetRelatedRecords (
00696          INT32 RecordNum,                                   //!< Record in the base table to get attachments for
00697          INT32 BaseTableNum,                                //!< Basetable that contains the record stated above
00698          SIMPLE_ARRAY<INT32>& RecordList,                   //!< List of records that are related RETURNED
00699          FINDFLAG FindFlags = FINDFLAG_AllAttached          //!< find flags
00700          ) const;
00701 
00702       //! Get the records from this table attached to the given record
00703       //! @return Number of records attached or <0 if error 
00704       INT32 GetRelatedRecords (
00705          const RECORD& record,                              //!< Record to get attachments for
00706          SIMPLE_ARRAY<INT32>& RecordList,                   //!< List of records that are related RETURNED
00707          FINDFLAG FindFlags = FINDFLAG_AllAttached          //!< find flags
00708          ) const;
00709 
00710       //! Get table number
00711       //! @return Table number
00712       INT32 GetTableNumber (
00713          ) const;
00714          
00715       //! Get table usage
00716       //! @return Table usage
00717       USAGE GetUsage (
00718          ) const;
00719          
00720       //! Get view position of table
00721       //! @return Table view position
00722       LRECT2D GetWindowRect (
00723          ) const;
00724          
00725       //! Is the table hidden?
00726       //! @return 'True' if the table is hidden
00727       bool IsHidden (
00728          ) const;
00729 
00730       //! Is table an internal (no storage representation) table
00731       //! @return 'True' if the table is internal
00732       bool IsInternal (
00733          ) const;
00734 
00735       //! Is table missing.  Occurs with linked tables
00736       //! @return 'True' if the table is missing
00737       bool IsMissing (
00738          ) const;
00739          
00740       //! Is table a prompt table.  Used for adding elements
00741       //! @return 'True' if the table is a prompt table
00742       bool IsPrompt (
00743          ) const;
00744 
00745       //! Is table valid.  Occurs with deleted tables
00746       //! @return 'True' if the table is valid
00747       bool IsValid (
00748          ) const;
00749 
00750       //! Can the table be written to?
00751       //! @return 'True' if the table is writable
00752       bool IsWritable (
00753          ) const;
00754 
00755       //! Link to an external table, field info returned in the LINKPARMS
00756       ERRVALUE Link (
00757          RVC::DBASE& parent,
00758          const RVC::OBJECTNAME& name,
00759          const RVC::OBJECTDESC& desc,
00760          const LINKPARMS& LinkParms,
00761          const char* Source = 0
00762          );
00763 
00764       //! Make a table
00765       ERRVALUE Make (
00766          RVC::DBASE& parent,
00767          const RVC::OBJECTNAME& name,
00768          const RVC::OBJECTDESC& desc,
00769          MAKEPARMS& MakeParms,
00770          const char* Source = 0
00771          );
00772 
00773       //! Open an existing table using the table name
00774       ERRVALUE Open (
00775          const RVC::DBASE& parent,
00776          const RVC::OBJECTNAME& TableName,
00777          OPENMODE mode = OPENMODE_Read,
00778          MDLGPARENT pwidget = 0
00779          );
00780 
00781       //! Open an existing table using the table name
00782       ERRVALUE Open (
00783          int DBaseID,
00784          const RVC::OBJECTNAME& TableName,
00785          OPENMODE mode = OPENMODE_Read,
00786          MDLGPARENT pwidget = 0
00787          );
00788 
00789       //! Open an existing table using the table index
00790       ERRVALUE Open (
00791          const RVC::DBASE& parent,
00792          INT32 TableNum,
00793          OPENMODE mode = OPENMODE_Read,
00794          MDLGPARENT pwidget = 0
00795          );
00796 
00797       //! Open an existing table using the table index
00798       ERRVALUE Open (
00799          int DBaseID,
00800          INT32 TableNum,
00801          OPENMODE mode = OPENMODE_Read,
00802          MDLGPARENT pwidget = 0
00803          );
00804 
00805       //! Open a table using another instance of that table
00806       ERRVALUE Open (
00807          const DBTABLE& twin,
00808          OPENMODE mode = OPENMODE_Read,
00809          MDLGPARENT pwidget = 0
00810          );
00811 
00812       //! Open an RVC::DBTABLE instance using a RVC::OBJITEM instance
00813       //!
00814       //! This method will attach and open the file and database table object if possible
00815       ERRVALUE Open (
00816          const RVC::OBJITEM& ObjItem,        //!< This contains the file and rvc object location information
00817          OPENMODE OpenMode = OPENMODE_Read,  //!< Mode in which to open the rvc object
00818          MDLGPARENT widget = 0               //!< Parent dialog handle, 0 for default handle
00819          );
00820 
00821       //! Open an <b>attached</b> RVC::DBTABLE instance.
00822       //! The instance must be attached for this to work.
00823       ERRVALUE Open (
00824          OPENMODE OpenMode = OPENMODE_Read,  //!< Mode in which to open the rvc object
00825          MDLGPARENT widget = 0               //!< Parent dialog handle, 0 for default handle
00826          );
00827 
00828       //! Read a record from the table using a record number into a pre-allocated buffer
00829       ERRVALUE Read (
00830          INT32 RecordNum, 
00831          RECORD& Record
00832          ) const {return (Read(0, RecordNum, 0, Record, RECACC_RecordNum));}
00833 
00834       //! Read a record from the table using a cursor into a pre-allocated buffer
00835       ERRVALUE Read (
00836          CURSOR& cursor,
00837          RECORD& Record
00838          ) const {return (Read(&cursor, 0, 0, Record, RECACC_Cursor));}
00839          
00840       //! Read a record from the table using a cursor / bookmark pair into a pre-allocated buffer
00841       ERRVALUE Read (
00842          CURSOR& cursor,
00843          const BOOKMARK& bookmark,
00844          RECORD& Record
00845          ) const {return (Read(&cursor, 0, &bookmark, Record, RECACC_Bookmark));}
00846          
00847       //! Read a record from the table using a record number into a pre-allocated buffer
00848       ERRVALUE ReadDefault (
00849          RECORD& Record
00850          ) const {return (Read(0, RECORD_New, 0, Record, RECACC_RecordNum));}
00851 
00852       ERRVALUE ReadConstraint (
00853          std::vector<CONSTRAINT>& ConstraintList
00854          ) const;
00855 
00856       //! Get a constant iterator to the first viable record in the table
00857       void RecordBegin (
00858          CONST_RECORDITERATOR& Iterator, 
00859          ITERATERECORD IterateRecord = ITERATERECORD_SkipDeleted,
00860          INT32 FieldNum = 0
00861          ) const;
00862 
00863       //! Get an iterator to the first viable record in the table
00864       void RecordBegin (
00865          RECORDITERATOR& Iterator, 
00866          ITERATERECORD IterateRecord = ITERATERECORD_SkipDeleted,
00867          INT32 FieldNum = 0
00868          );
00869 
00870       //! Remove duplicate records from the table
00871       ERRVALUE RemoveDuplicateRecords (
00872          );
00873 
00874       //! Remove unattached records from the table
00875       ERRVALUE RemoveUnattachedRecords (
00876          );
00877 
00878       //! Set the number of records in the table.  Does not work with ATTACHMENT_Identity tables
00879       ERRVALUE Resize (
00880          INT32 NewNumRecords,
00881          bool CleanDBList
00882          );
00883 
00884       //! Search field index with a value for the record match
00885       //! @return Number of matches or error < 0
00886       template <class _CT>
00887       INT32 SearchIndex (
00888          INT32 FieldNum,
00889          const _CT& item,
00890          const FIELDINFO& finfo, 
00891          INT32& offset, 
00892          INDEXSEARCH flag = INDEXSEARCH_ReturnIndexOffset
00893          ) const {return (MfIndexSearch(GetDatabaseID(), m_TableID, FieldNum, &item, finfo.GetFieldInfoPtr(), &offset, flag));}
00894 
00895       //! Search field index with a value that matches the field to search for the record match
00896       //! @return Number of matches or error < 0
00897       template <class _CT>
00898       INT32 SearchIndex (
00899          INT32 FieldNum,
00900          const _CT& item,           //!< MUST MATCH 'FieldNum' field type and size
00901          INT32& offset, 
00902          INDEXSEARCH flag = INDEXSEARCH_ReturnIndexOffset
00903          ) const {return (MfIndexSearch(GetDatabaseID(), m_TableID, FieldNum, &item, 0, &offset, flag));}
00904 
00905       //! Search field index with a double value for the match
00906       //! @return Number of matches or error < 0
00907       INT32 SearchIndex (
00908          INT32 FieldNum,
00909          double value,
00910          INT32& offset, 
00911          INDEXSEARCH flag
00912          ) const;
00913          
00914       //! Search field index with a string value for the match
00915       //! @return Number of matches or error < 0
00916       INT32 SearchIndex (
00917          INT32 FieldNum,
00918          const MISTRING& value,
00919          INT32& offset, 
00920          INDEXSEARCH flag
00921          ) const;
00922          
00923       //! Search field index with a value in the RECORD for the match
00924       //! @return Number of matches or error < 0
00925       INT32 SearchIndex (
00926          INT32 FieldNum,
00927          const RECORD& Record, 
00928          INT32 RecFieldNum,
00929          INT32& offset, 
00930          INDEXSEARCH flag
00931          ) const;
00932       
00933       //! Set table attachment type
00934       ERRVALUE SetAttachmentType (
00935          ATTACHMENT Attachment
00936          );
00937 
00938       //! Set the computed field query for a field
00939       ERRVALUE SetComputedFieldQuery (
00940          INT32 FieldNum,
00941          const MISTRING& QueryStr
00942          );
00943          
00944       //! Set table encoding
00945       void SetEncoding (
00946          CHAR_ENCODING Encoding
00947          );
00948 
00949       //! Modify specific table FIELDINFO
00950       ERRVALUE SetFieldInfo (
00951          INT32 FieldNum,
00952          const FIELDINFO& FieldInfo
00953          );
00954 
00955       //! Modify all table FIELDINFO's
00956       ERRVALUE SetFieldInfo (
00957          FIELDINFOARRAY& FieldArray
00958          );
00959 
00960       //! Modify all table FIELDINFO's
00961       ERRVALUE SetFieldInfo (
00962          FIELDINFOARRAY& FieldArray,
00963          const SIMPLE_ARRAY<int>& NewToOld
00964          );
00965 
00966       //! Set view position of table
00967       void SetWindowRect (
00968          const LRECT2D& rect
00969          );
00970 
00971       //! Write a record in the table using a record number from a buffer
00972       ERRVALUE Write (
00973          INT32 RecordNum, 
00974          RECORD& Record
00975          ) {return (Write(0, RecordNum, 0, Record, RECACC_RecordNum));}
00976 
00977       //! Write a record in the table using a cursor from a buffer
00978       ERRVALUE Write (
00979          CURSOR& cursor,
00980          RECORD& Record
00981          ) {return (Write(&cursor,0, 0, Record, RECACC_Cursor));}
00982 
00983       //! Write a record in the table using a cursor / bookmark pair from a buffer
00984       ERRVALUE Write (
00985          CURSOR& cursor,
00986          const BOOKMARK& bookmark,
00987          RECORD& Record
00988          ) {return (Write(&cursor, 0, &bookmark, Record, RECACC_Bookmark));}
00989 
00990       ERRVALUE WriteConstraint (
00991          const std::vector<CONSTRAINT>& ConstraintList
00992          );
00993 
00994    protected:
00995 
00996       #ifndef GENERATING_DOXYGEN_OUTPUT
00997       DBASE m_ParentObj;
00998       int m_TableID;
00999       
01000       int GetDatabaseID () const {return (m_ParentObj.m_DBaseID);}
01001 
01002       virtual bool v_IsValidTable (const RVC::DBTABLE& table);
01003       #endif // GENERATING_DOXYGEN_OUTPUT
01004       
01005    private:
01006       #ifndef GENERATING_DOXYGEN_OUTPUT
01007 
01008       enum RECACC {
01009          RECACC_RecordNum,
01010          RECACC_Cursor,
01011          RECACC_Bookmark
01012          };
01013 
01014       //! Implementation of RVC::OBJECT virtual methods
01015       virtual ERRVALUE v_CloseObject ();
01016       virtual ERRVALUE v_GetDescription (RVC::OBJECTDESC& Desc) const;
01017       virtual OBJTYPE v_GetDftObjectType () const;
01018       virtual ERRVALUE v_GetName (RVC::OBJECTNAME& Name) const;
01019       virtual bool v_IsObjectOpen () const;
01020       virtual ERRVALUE v_OpenObject (OPENMODE OpenFlags, MDLGPARENT parent);
01021 
01022       INT32 GetRecordSize () const;
01023          
01024       ERRVALUE Read (
01025          CURSOR* cursor,
01026          INT32 RecordNum,
01027          const BOOKMARK* bookmark,
01028          RECORD& Record,
01029          RECACC flags
01030          ) const;
01031 
01032       static void TableCallbackFunc (DBCALLBACKSTRUCT *cb, void *data);
01033 
01034       ERRVALUE Write (
01035          CURSOR* cursor,
01036          INT32 RecordNum,
01037          const BOOKMARK* bookmark,
01038          RECORD& Record,
01039          RECACC flags
01040          );
01041 
01042       ERRVALUE WriteBinary (
01043          CURSOR* cursor,
01044          INT32 RecordNum,
01045          const BOOKMARK* bookmark,
01046          INT32 FieldNum,
01047          const SIMPLE_ARRAY<UINT8>& binary,
01048          RECACC flags
01049          );
01050 
01051       ERRVALUE WriteMemo (
01052          CURSOR* cursor,
01053          INT32 RecordNum,
01054          const BOOKMARK* bookmark,
01055          INT32 FieldNum,
01056          const MISTRING& string,
01057          RECACC flags
01058          );
01059 
01060       friend class CURSOR;
01061       friend class DBASE_ELEMENT;
01062       #endif // GENERATING_DOXYGEN_OUTPUT
01063    };
01064 
01065 
01066 //! Class to represent database bookmarks used in ODBC
01067 class DBTABLE::BOOKMARK {
01068    public:
01069       
01070       //! Default constructor
01071       explicit BOOKMARK (
01072          UINT32 Bookmark = 0
01073          ) : m_Bookmark(Bookmark) {}
01074    
01075       //! Copy constructor
01076       BOOKMARK (
01077          const BOOKMARK& rhs
01078          ) : m_Bookmark(rhs.m_Bookmark) {}
01079 
01080       //! Assignment
01081       BOOKMARK& operator= (
01082          const BOOKMARK& rhs
01083          ) {
01084          if (this != &rhs) m_Bookmark = rhs.m_Bookmark;
01085          return (*this);
01086          }
01087    
01088       bool operator== (
01089          const BOOKMARK& rhs
01090          ) const {return (m_Bookmark == rhs.m_Bookmark);}
01091       
01092    private:
01093       #ifndef GENERATING_DOXYGEN_OUTPUT
01094       UINT32 m_Bookmark;
01095    
01096       friend class DBTABLE;
01097       friend class DBTABLE::CURSOR;
01098       friend class DBTABLE::RECORD;
01099       #endif // GENERATING_DOXYGEN_OUTPUT
01100    };
01101 
01102 
01103 //! Class to represent database table cursors used in ODBC
01104 class DBTABLE::CURSOR {
01105    public:
01106       enum FUNCTION {
01107          FUNCTION_None =         0x00000000,
01108          FUNCTION_Unique =       0x00000001,
01109          FUNCTION_Sorted =       0x00000002,
01110          FUNCTION_Equal =        0x00000004,
01111          FUNCTION_GreaterThan =  0x00000008,
01112          FUNCTION_LessThan =     0x00000010,
01113          FUNCTION_NotEqual =     0x00000020,
01114          FUNCTION_AND =          0x00000040,
01115          FUNCTION_OR =           0x00000080,
01116          FUNCTION_NoClear =      0x00000100, //!< Add to previous function
01117          FUNCTION_ForUpdate =    0x00000200  //!< To allow writes
01118          };
01119       
01120       //! Default constructor
01121       explicit CURSOR (
01122          const RVC::DBTABLE& table
01123          );
01124          
01125       //! Destructor
01126       ~CURSOR (
01127          );
01128          
01129       //! Equality
01130       bool operator== (
01131          const CURSOR& rhs
01132          ) const;
01133          
01134       //! Get the current bookmark     
01135       ERRVALUE GetBookmark (
01136          BOOKMARK& Bookmark
01137          ) const;
01138          
01139       //! Get the current record number or < 0 if error
01140       INT32 GetRecordNum (
01141          ) const;
01142          
01143       //! Is the cursor valid
01144       //! @return True for a valid cursor
01145       bool IsValid (
01146          ) const;
01147 
01148       //! Increment cursor
01149       //! @return > 0 if still valid, 0 if not, < 0 error
01150       int Next (
01151          );
01152          
01153       //! Reset cursor to the beginning
01154       ERRVALUE Rewind (
01155          );
01156 
01157       //! Set cursor behavior
01158       ERRVALUE SetFunction (
01159          INT32 FieldNum,
01160          FUNCTION Function
01161          );
01162    
01163    private:
01164       #ifndef GENERATING_DOXYGEN_OUTPUT
01165       const DBTABLE& m_Table;
01166       INT32 m_Value;
01167 
01168       CURSOR (const CURSOR& rhs);
01169       CURSOR& operator=(const CURSOR& rhs);
01170       
01171       friend class DBTABLE;
01172       friend class DBTABLE::RECORD;
01173       #endif // GENERATING_DOXYGEN_OUTPUT
01174    };
01175    
01176 
01177 //! Constraint class for the field in the table
01178 class DBTABLE::CONSTRAINT {
01179    public:
01180       enum CASE {
01181          CASE_None = 0,
01182          CASE_ForceUpperCase = 0x0100,
01183          CASE_ForceLowerCase = 0x0200,
01184          CASE_CapFirstLetter = 0x0400,
01185          CASE_CapFirstWord = 0x0800
01186          };
01187          
01188       enum PKTABLE {
01189          PKTABLE_None = 0,
01190          PKTABLE_MustExist = 0x00008000,
01191          PKTABLE_AutoAdd = 0x00010000,
01192          PKTABLE_AutoAddPrompt = 0x00020000
01193          };
01194    
01195       enum RANGEFLAG {
01196          RANGEFLAG_None = 0,
01197          RANGEFLAG_MinExclusive = 0x0001,
01198          RANGEFLAG_MaxExclusive = 0x0002,
01199          RANGEFLAG_MinInclusive = 0x0004,
01200          RANGEFLAG_MaxInclusive = 0x0008
01201          };
01202    
01203       //! Default Constructor
01204       CONSTRAINT (
01205          );
01206    
01207       //! Destructor
01208       ~CONSTRAINT (
01209          ) {}
01210 
01211       bool CanBeEmpty (
01212          ) const {return (!m_NotNull);}
01213          
01214       CASE GetCaseFlags (
01215          ) const {return (m_Case);}
01216       
01217       double GetDefaultNum (
01218          ) const {return (m_DefaultNum);}
01219          
01220       const MISTRING& GetPrefixLabel (
01221          ) const {return (m_Label);}
01222          
01223       const MISTRING& GetPostfixLabel (
01224          ) const {return (m_LabelAfter);}
01225          
01226       PKTABLE GetPkTableFlags (
01227          ) const {return (m_PkTable);}
01228       
01229       const DOUBLE_RANGE& GetRange (
01230          ) const {return (m_Range);}
01231          
01232       RANGEFLAG GetRangeFlags (
01233          ) const {return (m_RangeFlags);}
01234          
01235       bool IsAutoComplete (
01236          ) const {return (m_AutoComplete);}
01237          
01238       void SetAutoComplete (
01239          bool value
01240          ) {m_AutoComplete = value;}
01241          
01242       void SetCaseFlags (
01243          CASE flags
01244          ) {m_Case = flags;}
01245       
01246       void SetDefaultNum (
01247          double number
01248          ) {m_DefaultNum = number;}
01249          
01250       void SetEmpty (
01251          bool value
01252          ) {m_NotNull = !value;}
01253          
01254       void SetPrefixLabel (
01255          const MISTRING& label
01256          ) {m_Label = label;}
01257          
01258       void SetPostfixLabel (
01259          const MISTRING& label
01260          ) {m_LabelAfter = label;}
01261          
01262       void SetPkTableFlags (
01263          PKTABLE flags
01264          ) {m_PkTable = flags;}
01265       
01266       void SetRange (
01267          const DOUBLE_RANGE& range
01268          ) {m_Range = range;}
01269    
01270       void SetRangeFlags (
01271          RANGEFLAG flags
01272          ) {m_RangeFlags = flags;}
01273          
01274    private:
01275       #ifndef GENERATING_DOXYGEN_OUTPUT
01276    
01277       RANGEFLAG m_RangeFlags;
01278       CASE m_Case;
01279       PKTABLE m_PkTable;
01280       DOUBLE_RANGE m_Range;
01281       double m_DefaultNum;
01282       bool m_NotNull;
01283       bool m_AutoComplete;
01284       MISTRING m_Label;
01285       MISTRING m_LabelAfter;
01286       
01287       void GetConstraint (DBCONSTRAINT& rhs) const;
01288       void SetConstraint (const DBCONSTRAINT& rhs);
01289 
01290       friend class DBTABLE;
01291       #endif // GENERATING_DOXYGEN_OUTPUT
01292    };
01293 
01294 
01295 class DBTABLE::FIELDINFO {
01296    public:
01297 
01298       //!   pseudo fields for FIELDINFO.next_field.  Some database schemas
01299       //! require a 2 part key where the primary key is made up of 2 fields
01300       //! but the foreign key is made up of 1 field and the name of the field
01301       //! or one field and a "domid" which is looked up from a 3rd table by
01302       //! using the table/field name.  We look those up on import and record
01303       //! them in the FIELDINFO.domid.  I don't know of anything that would
01304       //! use the table name, but I added it for completeness 
01305       enum NEXTFIELD {
01306          NEXTFIELD_ThisFieldName = 0xFFFF,   //!< Name of this field is the key data 
01307          NEXTFIELD_ThisTableName = 0xFFFE,   //!< Name of this table is the key data 
01308          NEXTFIELD_DomID         = 0xFFFD,   //!< Key data is the "domid" field of this field 
01309          NEXTFIELD_PseudoField   = 0xFFFC    //!< If next_field is > this, it's one of these 
01310          };
01311          
01312       enum FLAGS {
01313          FLAG_None =             0x0000,
01314          FLAG_PrimaryKey =       0x0001,  //!< Field is a primary key (force index)
01315          FLAG_PK =               FLAG_PrimaryKey,
01316          FLAG_ForeignKey =       0x0002,  //!< Field is a foreign key (index optional)
01317          FLAG_FK =               FLAG_ForeignKey,
01318          FLAG_Indexed =          0x0004,  //!< Field has index 
01319          FLAG_NotNULL =          0x0010,  //!< Value cannot be NULL 
01320          FLAG_Unique =           0x0020,  //!< value must be unique 
01321          FLAG_ReadOnly =         0x0040,  //!< User can't change value 
01322          FLAG_SecondaryKey =     0x0080,  //!< Secondary (or higher) key 
01323          FLAG_SK =               FLAG_SecondaryKey,
01324          FLAG_Invisible =        0x0100,  //!< Don't show the field at all 
01325          FLAG_Closest =          0x0200,  
01326          FLAG_RangeAbove =       0x0400,  
01327          FLAG_RangeBelow =       0x0800,  
01328          FLAG_ComputeOnRead =    0x0008,  //!< Field is computed 
01329          FLAG_ComputeOnWrite =   0x1000,  //!< Compute field on write 
01330          FLAG_Computed =         0x1008,
01331          FLAG_LocalTime =        0x2000,  //!< TYPE_DateTime field is stored in local time
01332          FLAG_AutoIncrement =    0x4000   //!< Assignes the "AutoIncrement" value to the field and then increments "AutoIncrement" (default start is '1')
01333          };
01334 
01335       enum TYPE { 
01336          TYPE_Invalid = 0,       //!< Invalid field type
01337          TYPE_String = 1,        //!< ASCII character string, null-terminated 
01338          TYPE_Char = 2,          //!< Single ASCII character 
01339          TYPE_UByte = 3,         //!< Unsigned 1-byte integer (0-255)
01340          TYPE_Byte = 4,          //!< Signed 1-byte integer (-128-128)
01341          TYPE_UWord = 5,         //!< Unsigned 2-byte integer (0-65535)
01342          TYPE_Word = 6,          //!< Signed 2-byte integer (-32768-32767)
01343          TYPE_ULong = 7,         //!< Unsigned 4-byte integer (0 - 2^32-1)
01344          TYPE_Long = 8,          //!< Signed 4-byte integer (-2^31 - 2^31-1)
01345          TYPE_Float = 9,         //!< 4-byte floating-point number
01346          TYPE_Double = 10,       //!< 8-byte floating-point number
01347          TYPE_Logical = 11,      //!< 1-byte logical (?/Y/y/N/n/T/t/F/f/0/1)
01348          TYPE_Date = 12,         //!< 4-byte integer date YYYYMMDD
01349          TYPE_Color = 15,        //!< Color spec. Always 8 bytes (COLOR)
01350          TYPE_Binary = 16,       //!< Binary field
01351          TYPE_Memo = 17,         //!< Memo field
01352          TYPE_Unicode = 18,      //!< UNICODE string, null-terminated
01353          TYPE_DateTime = 19      //!< Date/Time field, 100-nanosecond intervals from 1-Jan-1601
01354          };
01355          
01356       enum USAGE {         
01357          USAGE_Undefined = 0,
01358          USAGE_XCoord = 1,
01359          USAGE_YCoord,
01360          USAGE_ZCoord,
01361          USAGE_Label,
01362          USAGE_Filename,
01363          USAGE_ObjName
01364          };
01365          
01366       //! Default constructor
01367       FIELDINFO (
01368          ) {memset(this, 0, sizeof(*this));}
01369 
01370       //! Clear the field info of current values
01371       void Clear (
01372          ) {memset(this, 0, sizeof(*this));}
01373          
01374       //! Compare two field types and return best field type to convert to
01375       //! @return this->GetType() if exact match, TYPE_??? depending if the types are
01376       //! not the best match but still matchable, TYPE_Invalid if types do not match
01377       TYPE CompareFieldTypes (
01378          const FIELDINFO& rhs,
01379          bool& ExactMatch              //!< Set to 'true' if the two fields match exactly, 'false' if they do not
01380          ) const;
01381          
01382       //! Get the AutoIncrement number for the next added record
01383       //! @return Next AutoIncrement number
01384       UINT32 GetAutoIncrement (
01385          ) const {return (m_FieldInfo.AutoIncrement);}
01386    
01387       //! Get number of decimal places to display for floating point fields
01388       //! @return Number of decimal places to display    
01389       int GetDecimalPlaces (
01390          ) const {return (m_FieldInfo.decplaces);}
01391          
01392       //! Get the display units for this field
01393       //! @return Display unit
01394       int GetDispUnits (
01395          ) const {return (m_FieldInfo.unitshown);}
01396          
01397       //! Get number of columns to display
01398       //! @return Number of columns to display     
01399       int GetDispWidth (
01400          ) const {return (m_FieldInfo.dispwidth);}
01401          
01402       //! Get the domain ID for this field
01403       //! @return Domain ID
01404       const RVC::OBJECTNAME& GetDomainID (
01405          ) const {return (m_FieldInfo.domid);}
01406          
01407       //! Get the flags for this field
01408       //! @return Field flags (FIELDINFO::FLAGS_...)
01409       FLAGS GetFlags (
01410          ) const {return (static_cast<FLAGS>(m_FieldInfo.flags));}
01411          
01412       //! Get the name of this field
01413       //! @return Field name
01414       const RVC::OBJECTNAME& GetName (
01415          ) const {return (m_FieldInfo.name);}
01416          
01417       //! Get the next field number that this field is linked to
01418       //! @return Next link field number
01419       INT32 GetNextLinkField (
01420          ) const {return (m_FieldInfo.next_field-1);}
01421          
01422       //! Get the next field pseudo number that this field is linked to
01423       //! @return Next link field pseudo number (FIELDINFO::NEXTFIELD_...)
01424       NEXTFIELD GetPseudoNextLinkField (
01425          ) const {return (static_cast<NEXTFIELD>(m_FieldInfo.next_field));}
01426          
01427       //! Get the field number that this field is linked to, use HasRelation() to 
01428       //! determine if the field is related to another table / field
01429       //! @return Linked field number
01430       INT32 GetRelatedField (
01431          ) const {return (m_FieldInfo.key_field-1);}
01432          
01433       //! Get the table number that this field is linked to, use HasRelation() to 
01434       //! determine if the field is related to another table / field
01435       //! @return Related table number
01436       INT32 GetRelatedTable (
01437          ) const {return (m_FieldInfo.key_table);}
01438          
01439       //! Get the size of the field in bytes
01440       //! @return Size of field in bytes
01441       INT32 GetSize (
01442          ) const {return (m_FieldInfo.size);}
01443          
01444       //! Get the type of the field
01445       //! @return Type of field (FIELDINFO::TYPE_...)
01446       TYPE GetType (
01447          ) const {return (static_cast<TYPE>(m_FieldInfo.type));}
01448    
01449       //! Get the numeric units for this field for unit conversion
01450       void GetUnits (
01451          UNITCONV& conv
01452          ) const {GetUnitConversion(m_FieldInfo.unittype, m_FieldInfo.unitstored, m_FieldInfo.unitshown, &conv);}
01453          
01454       //! Get the usage of the field
01455       //! @return Field usage (FIELDINFO::USAGE_...)
01456       USAGE GetUsage (
01457          ) const {return (static_cast<USAGE>(m_FieldInfo.usage));}
01458          
01459       //! Is the field related to another table / field
01460       //! @return 'True' if field is related
01461       bool HasRelation (
01462          ) const {return (m_FieldInfo.key_field > 0);}
01463    
01464       //! Does the field have a next key field link?
01465       //! @return 'True' if field has a next key field
01466       bool HasNextKey (
01467          ) const {return (m_FieldInfo.next_field > 0);}
01468    
01469       //! Does the field have a next key pseudo field link?
01470       //! @return 'True' if field has a next pseudo key field
01471       bool HasPseudoNextKey (
01472          ) const {return (m_FieldInfo.next_field > NEXTFIELD_PseudoField);}
01473          
01474       //! Is the field a nemeric field?  (not a string that can be converted to a number)
01475       //! @return 'True' if field is a numeric field
01476       bool IsNumeric (
01477          ) const {return (m_FieldInfo.type >= TYPE_UByte && m_FieldInfo.type <= TYPE_Double);}
01478 
01479       //! Reset position information about the field        
01480       void ResetPosition (
01481          ) {m_FieldInfo.offset = m_FieldInfo.diskoffset = m_FieldInfo.disksize = 0;}
01482          
01483       //! Set the AutoIncrement number for the next added record
01484       void SetAutoIncrement (
01485          UINT32 count
01486          ) {m_FieldInfo.AutoIncrement = count;}
01487    
01488       //! Set the number of decimal places for floating point fields
01489       void SetDecimalPlaces (
01490          int decplaces
01491          ) {m_FieldInfo.decplaces = static_cast<UINT8>(decplaces);}
01492          
01493       //! Set the display units for this field
01494       void SetDispUnits (
01495          int unit
01496          ) {m_FieldInfo.unitshown = static_cast<UINT8>(unit);}
01497          
01498       //! Set the display width (number of columns) for the field
01499       void SetDispWidth (
01500          int width
01501          ) {m_FieldInfo.dispwidth = static_cast<UINT8>(width);}
01502          
01503       //! Set the Domain ID for this field
01504       void SetDomainID (
01505          const RVC::OBJECTNAME& name
01506          ) {m_FieldInfo.domid = name;}
01507          
01508       //! Set field flags
01509       void SetFlags (
01510          FLAGS flags
01511          ) {m_FieldInfo.flags = flags;}
01512          
01513       //! Set this field to link to a field in another table