home *** CD-ROM | disk | FTP | other *** search
/ Delphi Anthology / aDELPHI.iso / Runimage / Delphi50 / Doc / drintf.int < prev    next >
Text File  |  1999-08-11  |  6KB  |  139 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Borland Delphi Visual Component Library         }
  5. {                                                       }
  6. {       Copyright (c) 1995,99 Inprise Corporation       }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit DRIntf;
  11.  
  12. interface
  13.  
  14. uses
  15.   SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms,
  16.   Dialogs, BDE, Db, DBTables;
  17.  
  18. type
  19.   TID = packed record Reserved: array[1..6] of Byte; end;
  20.   TDatabaseID = type TID;
  21.   TTableID = type TID;
  22.   TFieldID = type TID;
  23.   TAttrID = type TID;
  24.  
  25. const
  26.   NullID: TID = ();
  27.   NullAttrID: TAttrID = ();
  28.   NullDatabaseID: TDatabaseID = ();
  29.   NullTableID: TTableID = ();
  30.   NullFieldID: TFieldID = ();
  31.  
  32. function DictionaryActive: Boolean;
  33.  
  34. procedure DictionaryDeactivate;
  35.  
  36. function CurrentDictionary: HDBIDR;
  37.  
  38. { IsIDNull - Returns true if the given ID is a null ID }
  39. function IsNullID(const ID): Boolean;
  40.  
  41. { FindDatabaseID - Finds the ID for the given database.  Returns NullDatabaseID
  42.   the given database is not in the dictionary. }
  43. function FindDatabaseID(const Database: string): TDatabaseID;
  44.  
  45. { FindTableID - Finds the ID for the given table in the given database .
  46.   Returns NullTableID the given table is not in the dictionary. }
  47. function FindTableID(const Database: TDatabaseID; const Table: string): TTableID;
  48.  
  49. { FindFieldID - Find the ID for the given field in the given table.
  50.   Returns NullFieldID if the field is not in the dictionary }
  51. function FindFieldID(const Table: TTableID; const Field: string): TFieldID;
  52.  
  53. { FindAttrID - Finds the attribute set with the name EFAName.  Returns 0
  54.   if no attributes set by that name is found }
  55. function FindAttrID(const AttrName: string): TAttrID;
  56.  
  57. { GetAttrName - Returns the name of the attribute set AttrID }
  58. function GetAttrName(const AttrID: TAttrID): string;
  59.  
  60. { GetAttrNames - Calls Proc with the name of each attribute set in the
  61.   dictionary }
  62. procedure GetAttrNames(Proc: TGetStrProc);
  63.  
  64. { GetAttrID - Returns the ID of the attribute set associated with the given
  65.   field.  Returns null if the FieldID is null or is not valid, or if no
  66.   attribute set is associated with the field. }
  67. function GetAttrID(const FieldID: TFieldID): TAttrID;
  68.  
  69. { NewAttr - Creates a new attribute set from the given field component and
  70.   returns AttrID.  The new attribute set will inherit values from the
  71.   given Parent set, only differences between the sets are recorded.  If
  72.   Parent is a null string the attribute set is a root attribute set
  73.   and all the values in Field are recorded.  If FieldID is not 0 then
  74.   the new attribute set is associated with the field. }
  75. function NewAttr(Field: TField; const FieldID: TFieldID; const AttrName: string;
  76.   const Parent: TAttrID): TAttrID;
  77.  
  78. { UpdateAttr - Updates the AttrID attribute set.  If field is in the
  79.   Field dictionary then it the FieldID for the field should be supplied
  80.   since the attributes sets shouldn't store information that is the
  81.   matches the attributes field derived from the physical database.
  82.   If FieldID is supplied AttrID can be 0 which will update the attribute
  83.   set associated with the FieldID }
  84. procedure UpdateAttr(Field: TField; const FieldID: TFieldID;
  85.   const AttrID: TAttrID);
  86.  
  87. { CreateField - Creates a new field object from the information stored in
  88.   the field dictionary.  The new field is created owned by Owner and
  89.   belonging to Dataset.  The type and properties of the field are derived from
  90.   the field dictionary information.  Both FieldID and AttrID can be 0.
  91.   If FieldID is not 0 and AttrID is, the attribute set associated with FieldID
  92.   is used.  The Origin is the value of the Origin property for the new TField.
  93.   This can also be left blank ('') }
  94. function CreateField(Owner: TComponent; Dataset: TDataset; const FullName,
  95.   Origin: string; const FieldID: TFieldID; const AttrID: TAttrID): TField;
  96.  
  97. { UpdateField - Changes the properties of the given field to match the
  98.   attributes given field attribute set }
  99. procedure UpdateField(Field: TField; const FieldID: TFieldID;
  100.  const AttrID: TAttrID);
  101.  
  102. { AssociateAttr - Associates the given AttrID with the given FieldID }
  103. procedure AssociateAttr(const AttrID: TAttrID; const FieldID: TFieldID);
  104.  
  105. { UnassociateAttr - Removes the attribute set association for FieldID }
  106. procedure UnassociateAttr(const FieldID: TFieldID);
  107.  
  108. { GetControlClass - Returns the control class to create or '' if no control
  109.   class was specified }
  110. function GetControlClass(const AttrID: TAttrID): string;
  111.  
  112. { Returns a fully (user name) qualified table name if the database's tables are
  113.   stored in the dictionary qualified by user name }
  114. function QualifyTableName(Database: TDatabase; const TableName: string): string;
  115.  
  116. { Equivelent to QualifyTableName but first looks up the database by name
  117.   after finding the corresponding session. }
  118. function QualifyTableNameByName(const SessionName, DatabaseName, TableName: string): string;
  119.  
  120. { Returns whether the dataset has constraints recorded in the dictionary }
  121. function HasConstraints(Dataset: TDBDataset): Boolean;
  122.  
  123. { Will remove constraints marked FromDictionary and replace them with the
  124.   constraints recorded in the dictionary }
  125. procedure UpdateConstraints(Dataset: TDBDataset; Constraints: TCheckConstraints);
  126.  
  127. { UpdateDataset updates the given dataset to the current settings and
  128.   constraints in the dataset.  For a TTable it will update the fields associated
  129.   with that table and all of the constraints for that table.  For a query or
  130.   stored procedure, it will use the AttributeSet property of the TField's to
  131.   determine which attribute set to update the field with.  It will also parse
  132.   the query to for the associated tables and update the field record constraints
  133.   from the included tables. This is progromatically equivilent to using
  134.   "Retrieve attributes" for all of the fields in the fields editor followed by
  135.   "Read From Dictionary" in the Constraint's property editor. }
  136. procedure UpdateDataset(Dataset: TDBDataset);
  137.  
  138. implementation
  139.