home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161b.iso / full / delphi / RUNIMAGE / DELPHI30 / DOC / DRINTF.INT < prev    next >
Encoding:
Text File  |  1997-08-04  |  5.7 KB  |  130 lines

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