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