System.Net.URLClient.TURI

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

  TURI = record
  private
    FScheme: string;
    FUsername: string;
    FPassword: string;
    FHost: string;
    FPort: Integer;
    FPath: string;
    FQuery: string;
    FParams: TURIParameters;
    FFragment: string;
  private type
    TEncType = (URLEnc, FormEnc);
  private
    procedure ParseParams(Encode: Boolean = False);
    function FindParameterIndex(const AName: string): Integer;
    function GetParameter(const I: Integer): TURIParameter;
    function GetParameterByName(const AName: string): string;
    procedure SetParameter(const I: Integer; const Value: TURIParameter);
    procedure SetParameterByName(const AName: string; const Value: string);
    procedure DecomposeURI(const AURIStr: string);
    procedure SetUserName(const Value: string);
    procedure SetPassword(const Value: string);
    procedure SetHost(const Value: string);
    procedure SetPath(const Value: string);
    function EncodePath(const NewPath: string): string;
    procedure SetQuery(const Value: string);
    procedure SetParams(const Value: TURIParameters);
    class function DoEncode(const AValue: string; EncType: TEncType): string; static;
    class function URLParamEncode(const AValue: string): string; static; inline;
  public
    constructor Create(const AURIStr: string);
    function ToString: string;
    procedure ComposeURI(const AScheme, AUsername, APassword, AHostname: string; APort: Integer; const APath: string;
      const AParams: TURIParameters; const AFragment: string);
    procedure AddParameter(const AName, AValue: string); overload;
    procedure AddParameter(const AParameter: TURIParameter); overload; inline;
    procedure DeleteParameter(AIndex: Integer); overload;
    procedure DeleteParameter(const AName: string); overload;
    class function URLEncode(const AValue: string; SpacesAsPlus: Boolean = False): string; static;
    class function URLDecode(const AValue: string; PlusAsSpaces: Boolean = False): string; static;
    class function UnicodeToIDNA(const AHostName: string): string; static;
    class function IDNAToUnicode(const AHostName: string): string; static;
    class function PathRelativeToAbs(const RelPath: string; const Base: TURI): string; static;
    property Parameter[const I: Integer]: TURIParameter read GetParameter write SetParameter;
    property ParameterByName[const AName: string]: string read GetParameterByName write SetParameterByName;
    property Scheme: string read FScheme write FScheme;
    property Username: string read FUsername write SetUserName;
    property Password: string read FPassword write SetPassword;
    property Host: string read FHost write SetHost;
    property Port: Integer read FPort write FPort;
    property Path: string read FPath write SetPath;
    property Query: string read FQuery write SetQuery;
    property Params: TURIParameters read FParams write SetParams;
    property Fragment: string read FFragment write FFragment;
  end;

C++

struct DECLSPEC_DRECORD TURI
{
private:
    enum class DECLSPEC_DENUM TEncType : unsigned char { URLEnc, FormEnc };
private:
    System::UnicodeString FScheme;
    System::UnicodeString FUsername;
    System::UnicodeString FPassword;
    System::UnicodeString FHost;
    int FPort;
    System::UnicodeString FPath;
    System::UnicodeString FQuery;
#ifndef _WIN64
    System::DynamicArray<TNameValuePair> FParams;
#else /* _WIN64 */
    System::TArray__1<TNameValuePair> FParams;
#endif /* _WIN64 */
    System::UnicodeString FFragment;
    void __fastcall ParseParams(bool Encode = false);
    int __fastcall FindParameterIndex(const System::UnicodeString AName);
    TNameValuePair __fastcall GetParameter(const int I);
    System::UnicodeString __fastcall GetParameterByName(const System::UnicodeString AName);
    void __fastcall SetParameter(const int I, const TNameValuePair &Value);
    void __fastcall SetParameterByName(const System::UnicodeString AName, const System::UnicodeString Value);
    void __fastcall DecomposeURI(const System::UnicodeString AURIStr);
    void __fastcall SetUserName(const System::UnicodeString Value);
    void __fastcall SetPassword(const System::UnicodeString Value);
    void __fastcall SetHost(const System::UnicodeString Value);
    void __fastcall SetPath(const System::UnicodeString Value);
    System::UnicodeString __fastcall EncodePath(const System::UnicodeString NewPath);
    void __fastcall SetQuery(const System::UnicodeString Value);
#ifndef _WIN64
    void __fastcall SetParams(const System::DynamicArray<TNameValuePair> Value);
#else /* _WIN64 */
    void __fastcall SetParams(const System::TArray__1<TNameValuePair> Value);
#endif /* _WIN64 */
    static System::UnicodeString __fastcall DoEncode(const System::UnicodeString AValue, TEncType EncType);
    static System::UnicodeString __fastcall URLParamEncode(const System::UnicodeString AValue);
public:
    __fastcall TURI(const System::UnicodeString AURIStr);
    System::UnicodeString __fastcall ToString(void);
#ifndef _WIN64
    void __fastcall ComposeURI(const System::UnicodeString AScheme, const System::UnicodeString AUsername, const System::UnicodeString APassword, const System::UnicodeString AHostname, int APort, const System::UnicodeString APath, const System::DynamicArray<TNameValuePair> AParams, const System::UnicodeString AFragment);
#else /* _WIN64 */
    void __fastcall ComposeURI(const System::UnicodeString AScheme, const System::UnicodeString AUsername, const System::UnicodeString APassword, const System::UnicodeString AHostname, int APort, const System::UnicodeString APath, const System::TArray__1<TNameValuePair> AParams, const System::UnicodeString AFragment);
#endif /* _WIN64 */
    void __fastcall AddParameter(const System::UnicodeString AName, const System::UnicodeString AValue)/* overload */;
    void __fastcall AddParameter(const TNameValuePair &AParameter)/* overload */;
    void __fastcall DeleteParameter(int AIndex)/* overload */;
    void __fastcall DeleteParameter(const System::UnicodeString AName)/* overload */;
    static System::UnicodeString __fastcall URLEncode(const System::UnicodeString AValue, bool SpacesAsPlus = false);
    static System::UnicodeString __fastcall URLDecode(const System::UnicodeString AValue, bool PlusAsSpaces = false);
    static System::UnicodeString __fastcall UnicodeToIDNA(const System::UnicodeString AHostName);
    static System::UnicodeString __fastcall IDNAToUnicode(const System::UnicodeString AHostName);
    static System::UnicodeString __fastcall PathRelativeToAbs(const System::UnicodeString RelPath, const TURI &Base);
    __property TNameValuePair Parameter[const int I] = {read=GetParameter, write=SetParameter};
    __property System::UnicodeString ParameterByName[const System::UnicodeString AName] = {read=GetParameterByName, write=SetParameterByName};
    __property System::UnicodeString Scheme = {read=FScheme, write=FScheme};
    __property System::UnicodeString Username = {read=FUsername, write=SetUserName};
    __property System::UnicodeString Password = {read=FPassword, write=SetPassword};
    __property System::UnicodeString Host = {read=FHost, write=SetHost};
    __property int Port = {read=FPort, write=FPort};
    __property System::UnicodeString Path = {read=FPath, write=SetPath};
    __property System::UnicodeString Query = {read=FQuery, write=SetQuery};
#ifndef _WIN64
    __property System::DynamicArray<TNameValuePair> Params = {read=FParams, write=SetParams};
#else /* _WIN64 */
    __property System::TArray__1<TNameValuePair> Params = {read=FParams, write=SetParams};
#endif /* _WIN64 */
    __property System::UnicodeString Fragment = {read=FFragment, write=FFragment};
    TURI() {}
};

Properties

Type Visibility Source Unit Parent
record
struct
public
System.Net.URLClient.pas
System.Net.URLClient.hpp
System.Net.URLClient System.Net.URLClient

Description

Record type to compose/decompose a URI from/into its parts.

TURI is a record type to compose/decompose a URI from/into its parts.

See Also