System.SysUtils.TFormatSettings
Delphi
TFormatSettings = record strict private {$IF DEFINED(MSWINDOWS) OR DEFINED(LINUX)} class function AdjustLocaleName(const LocaleName: string): string; static; class procedure GetDayNames(Locale: TLocaleID; var AFormatSettings: TFormatSettings); static; class procedure GetMonthNames(Locale: TLocaleID; var AFormatSettings: TFormatSettings); static; class function GetString(Locale: TLocaleID; LocaleItem, DefaultIndex: Integer; const DefaultValues: array of Pointer): string; static; {$ENDIF} {$IF DEFINED(MACOS)} class procedure GetDayNames(Formatter: CFDateFormatterRef; var AFormatSettings: TFormatSettings); static; class procedure GetMonthNames(Formatter: CFDateFormatterRef; var AFormatSettings: TFormatSettings); static; {$ENDIF} class function TranslateDateFormat(Locale: TLocaleID; LocaleType: Integer; const Default: string; const Separator: Char): string; static; public CurrencyString: string; CurrencyFormat: Byte; CurrencyDecimals: Byte; DateSeparator: Char; TimeSeparator: Char; ListSeparator: Char; ShortDateFormat: string; LongDateFormat: string; TimeAMString: string; TimePMString: string; ShortTimeFormat: string; LongTimeFormat: string; ShortMonthNames: array[1..12] of string; LongMonthNames: array[1..12] of string; ShortDayNames: array[1..7] of string; LongDayNames: array[1..7] of string; ThousandSeparator: Char; DecimalSeparator: Char; TwoDigitYearCenturyWindow: Word; NegCurrFormat: Byte; class function Create: TFormatSettings; overload; static; inline; class function Create(Locale: TLocaleID): TFormatSettings; overload; platform; static; class function Create(const LocaleName: string): TFormatSettings; overload; static; end;
C++
struct DECLSPEC_DRECORD TFormatSettings{ private: typedef System::StaticArray<System::UnicodeString, 12> _TFormatSettings__1; typedef System::StaticArray<System::UnicodeString, 12> _TFormatSettings__2; typedef System::StaticArray<System::UnicodeString, 7> _TFormatSettings__3; typedef System::StaticArray<System::UnicodeString, 7> _TFormatSettings__4; private: static System::UnicodeString __fastcall AdjustLocaleName(const System::UnicodeString LocaleName); static void __fastcall GetDayNames(unsigned Locale, TFormatSettings &AFormatSettings); static void __fastcall GetMonthNames(unsigned Locale, TFormatSettings &AFormatSettings); static System::UnicodeString __fastcall GetString(unsigned Locale, int LocaleItem, int DefaultIndex, void * const *DefaultValues, const int DefaultValues_Size); static System::UnicodeString __fastcall TranslateDateFormat(unsigned Locale, int LocaleType, const System::UnicodeString Default, const System::WideChar Separator); public: System::UnicodeString CurrencyString; System::Byte CurrencyFormat; System::Byte CurrencyDecimals; System::WideChar DateSeparator; System::WideChar TimeSeparator; System::WideChar ListSeparator; System::UnicodeString ShortDateFormat; System::UnicodeString LongDateFormat; System::UnicodeString TimeAMString; System::UnicodeString TimePMString; System::UnicodeString ShortTimeFormat; System::UnicodeString LongTimeFormat; _TFormatSettings__1 ShortMonthNames; _TFormatSettings__2 LongMonthNames; _TFormatSettings__3 ShortDayNames; _TFormatSettings__4 LongDayNames; System::WideChar ThousandSeparator; System::WideChar DecimalSeparator; System::Word TwoDigitYearCenturyWindow; System::Byte NegCurrFormat; static TFormatSettings __fastcall Create()/* overload */; static TFormatSettings __fastcall Create(unsigned Locale)/* overload */; static TFormatSettings __fastcall Create(const System::UnicodeString LocaleName)/* overload */; };
Eigenschaften
| Typ | Sichtbarkeit | Quelle | Unit | Übergeordnet |
|---|---|---|---|---|
record struct |
public | System.SysUtils.pas System.SysUtils.hpp |
System.SysUtils | System.SysUtils |
Beschreibung
TFormatSettings definiert einen Thread-sicheren String-Formatierungskontext.
TFormatSettings definiert eine Datenstruktur mit Gebietsschema-Informationen, die von String-Formatierungsroutinen verwendet werden. Jedes Element von TFormatSettings entspricht der gleichnamigen globalen Variable. Eine Variable des Typs TFormatSettings definiert einen Thread-sicheren Kontext, den Formatierungsfunktionen anstelle des globalen Standardkontextes (der nicht Thread-sicher ist) verwenden.
So erstellen und verwenden Sie die von TFormatSettings definierte Thread-sichere Umgebung:
- Definieren Sie eine Variable des Typs TFormatSettings.
- Rufen Sie TFormatSettings.Create auf, um die Gebietsschema-Informationen in die TFormatSettings-Variable zu schreiben.
- Übergeben Sie die TFormatSettings-Variable als letzten Parameter an die String-Formatierungsroutine.
Jede Routine, die einen TFormatSettings-Parameter entgegennimmt, ist Thread-sicher und eine überladene Version der entsprechenden Funktion, in der die globalen Formatierungsvariablen verwendet werden.