Unit Scope Names
Go Up to Getting Started with RAD Studio
Unit scope names are prefixes that are prepended to unit names in the RAD Studio libraries (VCL-FMX-RTL).
That is, names of units, functions, classes, and members have a unit scope name prepended to the unit name, as follows:
Syntax and Description
The unit scope name precedes the unit name:
<unitscope>.<unitname>. ...
For example, the SysUtils unit is now part of the System unit scope, as follows:
System.SysUtils
and the Controls unit is part of the Vcl or the FMX unit scope: Vcl.Controls
FMX.Controls
Contents
Unit scope names:
- Classify units into basic groups such as Vcl, System, FMX, and so forth (unit scopes are classified in Unit Scopes).
- Ensure compatibility of the code that you write using the IDE.
- Differentiate members whose names are ambiguous (that is, ensure correct name resolution when a member's name matches the name of a member of another unit).
- Typically begin with a single uppercase letter followed by lowercase letters (such as Data).
- Are typically made up of one element(such as DataSnap), although some are made up of two elements (such as System.Generics).
Component developers can add unit scope names as described in Adding Unit Scope Names for Your Own Components.
Fully Qualified Names Must Include the Unit Scope Name
With one notable exception, legacy code should continue to work without changes. The one exception is scoped or qualified identifiers in the code itself. Fully qualified identifier names now require unit scoping. This means that if you used qualified identifiers in your existing code (which was not unit-scoped), changes are required in order to compile. You need to add the unit scope name to the unit name.
For example, here is the fully qualified identifier of the TStream classthat you might have specified in previous product releases:
Classes.TStream
The name Classes.TStream is not considered to be a fully qualified class name because fully qualified names must be unit-scoped, that is, they must include the unit scope name. In this case, the unit scope name System must be added to the Classes unit name in order to yield a unit-scoped or fully qualified name, as follows:
- In Delphi, the fully qualified identifier name for TStream is:
System.Classes.TStream
- In C++, unit scope names use the C++ scope operator (
::
). The fully qualified name for the TStream class in C++ code is:System::Classes::TStream
Possible code changes: If your existing code contains qualified identifiers (such as Classes.TStream.Seek
), you must correct the name so that the identifier is unit-scoped and fully qualified (such as System.Classes.TStream.Seek
).
How to Specify Unit-Scoped Unit Names in Your Code
For new development, you must specify the unit scope for units in your application. Choose any of the following ways to do this:
- Everywhere:
- Fully qualify all names of all members throughout your code. Using full qualification, including unit scope names, throughout your application ensures the fastest compile time.
- Uses clause or #includes:
- Fully qualify unit names (with the unit scope and unit names) in the
uses
clause or#include
. Then in your code, you can partially qualify the names of members of those units that you fully qualified (with unit scope) in theuses
clause or#include
.
- Fully qualify unit names (with the unit scope and unit names) in the
- In Project Options:
- Add the unit scope names in the Unit scope names option on the Delphi Compiler page in Project Options.
RAD Studio Uses Unit Scopes, and the Help Also Uses Unit Scope Names
The wizards and templates in RAD Studio use and include properly unit-scoped unit names. In the help, some instances of unit, class, and member names do not include the unit scope names. However, the Libraries documentation has full unit scope names in the page titles.
Example
If your code contains:
uses
System.SysUtils, System.Types, System.Classes, FMX.Controls;
or:
#include <System.SysUtils.hpp>
#include <System.Types.hpp>
#include <System.Classes.hpp>
#include <FMX.Controls.hpp>
You can specify unqualified member names in your code, such as:
GetPackageInfo // referring to System.SysUtils.GetPackageInfo TRect // referring to System.Types.TRect TNotifyEvent // referring to System.Classes.TNotifyEvent TTrackBar // referring to FMX.Controls.TTrackBar
Unit Scopes
There are more than a few unit scopes, but most of the unit scopes can be grouped into a few general categories. The following table lists the general categories and the unit scope names in each category:
General Category | Unit Scope Names in this Category |
---|---|
Database-related |
Bde,Data, Data.Bind, Data.Cloud, Datasnap, Datasnap.Win,IB (also System.Bindings) |
FireMonkey |
FMX, FMX.ASE, FMX.Bind, FMX.Canvas, FMX.DAE, FMX.Filter, FMX.Platform, FMX.Printer |
iOS |
iOSapi (RTL) |
macOS |
Macapi, Posix, System.Mac (RTL) |
System-related (Run-Time Library) |
System, System.Bindings, System.Generics, System.Math, System.Sensors, System.Tether, System.Win |
Vcl (Visual Component Library) |
Vcl, Vcl.Imaging, Vcl.Samples, Vcl.Shell, Vcl.Touch |
SOAP, COM |
|
Web-related |
|
Windows API |
Winapi (RTL) |
XML processing |
Xml, Xml.Internal, Xml.Win |
- Ten unit scopes are FireMonkey related (FMX, FMX.ASE, FMX.Bind, FMX.Canvas, FMX.DAE, FMX.DateTimeControls, FMX.EmbeddedControls, FMX.Filter, FMX.ListView, FMX.MediaLibrary).
- The Soap unit scope contains COM-related units.
- The System unit scope has several unit scopes, including System.Bindings, System.Generics, System.Math, System.Sensors, System.Tether).
- Four unit scopes are VCL related (Vcl, Vcl.Imaging, Vcl.Samples, Vcl.Touch).
- The Xml unit scope contains the four units related to XML processing, such as Xml.Win.msxmldom.
Unit Scopes and the Units in Each Unit Scope
The following table gives the following information:
- For units that are documented in the help, a hyperlink is given to the unit scope, where you will see the units that belong in the unit scope.
- For external units, which are not documented in the help, the units are listed that belong in the unit scope.
Unit Scope Name | Units |
---|---|
Androidapi (RTL) |
AppGlue, AssetManager, AssetManagaerIni, Bitmap, Configuration, Consts, Egl, Eglext, EglPlatform Gles, Gles2, Gles2ext, Glesext, Input, IOUtils, JNI.Analytics, JNI.ApkExpansion, JNI.App, JNI.Dalvik, JNI.Embarcadero, JNI.GraphicsContentViewText, JNI.Hardware, JNI.InputMethodService, JNI.JavaTypes, JNI.Licensing, JNI.Location, JNI.Media, JNI.Net, JNI.OpenGL, JNI.Os, Jni, JNI.PlayServices, JNI.Provider, JNI.Support, JNI.Telephony, JNI.Util, JNI.VideoView, JNI.WebKit, JNI.Widget, JNIBridge, JNIMarshal, Keycodes, KhrPlatform, Log, Looper, NativeActivity, NativeWindow, NativeWindowJni, Obb, OpenSles, Rect, Sensor, StorageManager |
See Data | |
See Data.Bind | |
See Data.Cloud | |
See Datasnap | |
See FMX | |
See IBX | |
iOSapi (RTL) |
AssetsLibrary, AVFoundation, CocoaTypes, CoreAudio, CoreData, CoreGraphics, CoreImage, CoreLocation, CoreMedia, CoreMotion, CoreTelephony, CoreText, CoreVideo, Foundation, GLKit, MediaPlayer, OpenGLES, QuartzCore, UIKit |
Macapi (RTL) (Mac Objective-C Frameworks) |
AppKit, AVFoundation, CocoaTypes, CoreFoundation, CoreServices, Foundation, Mach, ObjCRuntime, ObjectiveC, OCMarshal, OpenGL, QuartzCore, Security, SystemConfiguration, VarObjC |
Posix |
ArpaInet, Base, Dirent, Dlfcn, Errno, Fcntl, Fnmatch, Grp, Iconv, Langinfo, Limits, Locale, NetDB, NetIf, NetinetIcmp6, NetinetIn, NetinetIp6, Posix, Pthread, Pwd, Sched, Semaphore, Signal, StdDef, Stdio, Stdlib, String_, StrOpts, SysMman, SysSelect, SysSocket, SysStat, SysStatvfs, SysSysctl, SysTime, SysTimes, Systypes, SysUio, SysWait, Termios, Time, Unistd, Utime, Wchar, Wctype, Wordexp |
See Soap | |
See SysInit | |
See System | |
See System.Win | |
See Vcl | |
See Web | |
See Winapi | |
See Xml |