System.SysUtils.TFormatSettings

De Appmethod Libraries
Aller à : navigation, rechercher

Object Pascal

  TFormatSettings = record
  public
    type
      TEraInfo = record
        EraName: string;
        EraOffset: Integer;
        EraStart: TDate;
        EraEnd: TDate;
      end;
  strict private
{$IF defined(MSWINDOWS) OR defined(USE_LIBICU) OR defined(LINUX)}
    class procedure GetDayNames(Locale: TLocaleID; var AFormatSettings: TFormatSettings); static;
    class procedure GetMonthNames(Locale: TLocaleID; var AFormatSettings: TFormatSettings); static;
    class procedure GetEraInformation(Locale: TLocaleID; var AFormatSettings: TFormatSettings); static;
 {$IF defined(MSWINDOWS) OR defined(LINUX)}
    class function GetString(Locale: TLocaleID; LocaleItem, DefaultIndex: Integer;
      const DefaultValues: array of Pointer): string; static;
 {$ENDIF defined(MSWINDOWS)}
{$ELSEIF defined(MACOS)}
    class procedure GetEraInformation(Locale: TLocaleID; Formatter: CFDateFormatterRef; var AFormatSettings: TFormatSettings); static;
    class procedure GetDayNames(Formatter: CFDateFormatterRef; var AFormatSettings: TFormatSettings); static;
    class procedure GetMonthNames(Formatter: CFDateFormatterRef; var AFormatSettings: TFormatSettings); static;
{$ENDIF}
    class function AdjustLocaleName(const LocaleName: string): string; static;
    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;
    EraInfo: array of TEraInfo;
    ThousandSeparator: Char;
    DecimalSeparator: Char;
    TwoDigitYearCenturyWindow: Word;
    NegCurrFormat: Byte;
    NormalizedLocaleName: string;
    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;
    class function Invariant: TFormatSettings; static;
    function GetEraYearOffset(const Name: string): Integer;
  end;

C++

struct DECLSPEC_DRECORD TFormatSettings
{
public:
    struct DECLSPEC_DRECORD TEraInfo
    {
    public:
        System::UnicodeString EraName;
        int EraOffset;
        System::TDate EraStart;
        System::TDate EraEnd;
    };
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;
    typedef System::DynamicArray<TEraInfo> _TFormatSettings__5;
private:
    static void __fastcall GetDayNames(unsigned Locale, TFormatSettings &AFormatSettings);
    static void __fastcall GetMonthNames(unsigned Locale, TFormatSettings &AFormatSettings);
    static void __fastcall GetEraInformation(unsigned Locale, TFormatSettings &AFormatSettings);
    static System::UnicodeString __fastcall GetString(unsigned Locale, int LocaleItem, int DefaultIndex, void * const *DefaultValues, const int DefaultValues_High);
    static System::UnicodeString __fastcall AdjustLocaleName(const System::UnicodeString LocaleName);
    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;
    _TFormatSettings__5 EraInfo;
    System::WideChar ThousandSeparator;
    System::WideChar DecimalSeparator;
    System::Word TwoDigitYearCenturyWindow;
    System::Byte NegCurrFormat;
    System::UnicodeString NormalizedLocaleName;
    static TFormatSettings __fastcall Create()/* overload */;
    static TFormatSettings __fastcall Create(unsigned Locale)/* overload */;
    static TFormatSettings __fastcall Create(const System::UnicodeString LocaleName)/* overload */;
    static TFormatSettings __fastcall Invariant();
    int __fastcall GetEraYearOffset(const System::UnicodeString Name);
};

Propriétés

Type Visibilité  Source Unité  Parent
record
struct
public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils

Description

TFormatSettings définit un contexte de formatage de chaînes thread-safe.

TFormatSettings définit une structure de données contenant des informations locales utilisées par la routine de formatage de chaînes. Chaque membre de TFormatSettings est équivalent à la variable globale de même nom. Une variable de type TFormatSettings définit un contexte thread-safe utilisable par les fonctions de formatage à la place du contexte global par défaut (lequel n'est pas thread-safe).

Pour créer et utiliser l'environnement thread-safe défini par TFormatSettings, procédez comme suit :

  1. Définissez une variable de type TFormatSettings.
  2. Appelez TFormatSettings.Create pour remplir la variable TFormatSettings avec des informations locales.
  3. Passez la variable TFormatSettings en tant que dernier paramètre de la routine de formatage de chaînes.

Chaque routine acceptant un paramètre TFormatSettings est thread-safe, et est une surcharge d'une fonction équivalente qui se réfère aux variables de formatage globales.

Examples de code