I have a relatively complicated data structure to model. I would like to do this with a record structure in Delphi, and the structure is complicated enough to justify splitting this into nested records. A simplified example:
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 ~~~~~~
I currently have all this declared in the Interface section of the unit. I would prefer if only the main record structure was visible to anything using the unit, and at the moment all the sub records are also visible. If I move the record declarations into the Implementation section then I get compiler errors. How do I restructure so that I declare the sub-records prior to the main record but the sub-records are not published?