我有一个相对复杂的数据结构来建模。我想用 Delphi 中的记录结构来做到这一点,并且结构足够复杂,足以证明将其拆分为嵌套记录是合理的。一个简化的例子:
type
TVertAngle = record
strict private
fDecDegrees: Double;
fDegrees: integer;
fMinutes: integer;
fDeciSeconds: integer;
function GetAngle: Double;
function GetRadians: Double;
public
Valid: Boolean;
procedure SetAsString(const Value: string; const AngleType: TInfoUnits);
property DecDegrees: Double read GetAngle;
property Radians: Double read GetRadians;
end;
~~~~ other sub record declarations ~~~~~~
TDataRecord = record
strict private
fHorzDistance: Double;
fLeicaData: TRawMessageData;
fUpdateTime: TDateTime;
function DecodeGsi8(GsiWord: string): TGSiWord;
function DecodeGsi16(GsiWord: string): TGSiWord;
public
GsiWord: TGSiWord;
Valid: Boolean;
InputMode: TDataModes;
HorzAngle: THorzAngle;
VertAngle: TVertAngle;
HorzRange: TDistance;
SlopeRange: TDistance;
PrismOffset: TConstants;
~~~~ other sub record instances~~~~~~
function SetMessage(RawMessage: string): Boolean;
~~~~ more stuff ~~~~~~
我目前在单元的接口部分中声明了所有这些。如果只有主记录结构对使用该单元的任何内容可见,并且目前所有子记录也可见,我会更喜欢。如果我将记录声明移动到实施部分,则会出现编译器错误。如何重组,以便在主记录之前声明子记录但不发布子记录?