Unicorn XML Toolkit
Version 1.50.00

Namespace Uri
Class CUri

class CUri {
public:
    CUri();
    ~CUri();
public:
    void Create(const WCHAR *pszSource);
    const WCHAR *GetSource();
    bool IsAbsolute();
    bool GetScheme(CString &strScheme);
    bool GetAuthority(CString &strAuthority);
    bool IsRelativePath();
    int GetSegmentCount();
    CString GetSegment(int nIndex);
    bool GetQuery(CString &strQuery);
    bool GetOpaquePart(CString &strOpaquePart);
    bool GetFragment(CString &strFragment);
    CString ResolveUri(const WCHAR *pszUri);
public:
    static bool FileNameToUri(
        const WCHAR *pszFileName, CString &strUri);
    static bool UriToFileName(
        const WCHAR *pszUri, CString &strFileName);
    };

The representation for the Universal Resource Identifier (URI).

Member functions of this class can be used for fetching URI components and for resolution of relative URI. Furthermore, few static functions provide conversions between URI and file path names of the local file system.

Since:
1.00.00
Version:
1.50.00
Author:
Alexey Gokhberg
Constructor/Destructor Summary
CUri ();
����������Constructs the URI.
~CUri ();
����������Destroys the URI.

Function Summary
void Create (const WCHAR *pszSource);
����������Creates the URI from the specified source string containing the URI text.
const�WCHAR�* GetSource ();
����������Returns a source string containing the text of this URI.
bool IsAbsolute ();
����������Tests whether this URI is absolute (that is, conforms to the absoluteURI syntax defined by RFC 2396).
bool GetScheme (CString &strScheme);
����������Returns a string representing the scheme component of this URI.
bool GetAuthority (CString &strAuthority);
����������Returns a string representing the authority component of this URI.
bool IsRelativePath ();
����������Tests whether this URI is relative and contains a relative path component (that is, a component which conforms to the rel_path syntax rule defined by RFC 2396).
int GetSegmentCount ();
����������Returns a number of segments in the path of this URI.
CString GetSegment (int nIndex);
����������Returns a string representing a segment in the path of this URI at the specified index.
bool GetQuery (CString &strQuery);
����������Returns a string representing the query component of this URI.
bool GetOpaquePart (CString &strOpaquePart);
����������Returns a string representing the opaque_part component of this URI.
bool GetFragment (CString &strFragment);
����������Returns a string representing the fragment component of this URI.
CString ResolveUri (const WCHAR *pszUri);
����������Resolves a specified relative URI using this URI object as the base.
bool FileNameToUri (const WCHAR *pszFileName, CString &strUri);
����������Converts a file path to an URI.
bool UriToFileName (const WCHAR *pszUri, CString &strFileName);
����������Converts an absolute URI to a file path.

Constructor/Destructor Detail

CUri

CUri();

Constructs the URI.

The contents of URI remains unspecified until the member function Create is called.

~CUri

~CUri();

Destroys the URI.

Function Detail

Create

void Create(const WCHAR *pszSource);

Creates the URI from the specified source string containing the URI text.

Parameters:
pszSource - the source string containing the URI text

GetSource

const WCHAR *GetSource();

Returns a source string containing the text of this URI.

Returns:
the source string containing the text of this URI

IsAbsolute

bool IsAbsolute();

Tests whether this URI is absolute (that is, conforms to the absoluteURI syntax defined by RFC 2396).

Returns:
true if this URI is absolute; false otherwise

GetScheme

bool GetScheme(CString &strScheme);

Returns a string representing the scheme component of this URI.

Parameters:
strScheme - on return, the string representing the scheme component of this URI; unspecified if this component is not present
Returns:
true if the scheme component is present in this URI; false otherwise

GetAuthority

bool GetAuthority(CString &strAuthority);

Returns a string representing the authority component of this URI.

Parameters:
strAuthority - on return, the string representing the authority component of this URI; unspecified if this component is not present
Returns:
true if the authority component is present in this URI; false otherwise

IsRelativePath

bool IsRelativePath();

Tests whether this URI is relative and contains a relative path component (that is, a component which conforms to the rel_path syntax rule defined by RFC 2396).

Returns:
true if this URI is relative and contains a relative path component; false otherwise

GetSegmentCount

int GetSegmentCount();

Returns a number of segments in the path of this URI.

Each segment and rel_segment component is counted as a segment. If this URI is absolute and contains opaque_part , the number of segments is 0 .

Returns:
the number of segments in the path of this URI

GetSegment

CString GetSegment(int nIndex);

Returns a string representing a segment in the path of this URI at the specified index.

Parameters:
nIndex - the index (zero-based)
Returns:
the string representing a segment in the path of this URI at the specified index

GetQuery

bool GetQuery(CString &strQuery);

Returns a string representing the query component of this URI.

Parameters:
strQuery - on return, the string representing the query component of this URI; unspecified if this component is not present
Returns:
true if the query component is present in this URI; false otherwise

GetOpaquePart

bool GetOpaquePart(CString &strOpaquePart);

Returns a string representing the opaque_part component of this URI.

Parameters:
strOpaquePart - on return, the string representing the opaque_part component of this URI; unspecified if this component is not present
Returns:
true if the opaque_part component is present in this URI; false otherwise

GetFragment

bool GetFragment(CString &strFragment);

Returns a string representing the fragment component of this URI.

Parameters:
strFragment - on return, the string representing the fragment component of this URI; unspecified if this component is not present
Returns:
true if the fragment component is present in this URI; false otherwise

ResolveUri

CString ResolveUri(const WCHAR *pszUri);

Resolves a specified relative URI using this URI object as the base.

If the specified URI is absolute, it is returned unchanged as the result of this function. If the specified URI is relative, it is resolved as specified in RFC 2396, section "5.2. Resolving Relative References to Absolute Form"; the URI represented by this URI object is used as the base URI.

It is an error if the URI represented by this object is not absolute.

Parameters:
pszUri - the URI to resolve
Returns:
the string representation of the absolute URI, obtained as the result of URI resolution

FileNameToUri

static bool FileNameToUri(
    const WCHAR *pszFileName, CString &strUri);

Converts a file path to an URI.

The file path syntax is platform-dependent. The conversion algorithm is platform-dependent.

Relative file path strings are resolved to the absolute form in the platform-dependent way.

The conversion may fail due to the invalid syntax of the input file path.

Parameters:
pszFileName - the input file path string
strUri - on return, the URI string obtained as the result of conversion; unspecified if conversion failed
Returns:
true if conversion was successful; false if conversion failed

UriToFileName

static bool UriToFileName(
    const WCHAR *pszUri, CString &strFileName);

Converts an absolute URI to a file path.

The file path syntax is platform-dependent. The conversion algorithm is platform-dependent.

The input URI must represent an absolute file URI, that is, it must start with "file:///" or "file://localhost/" .

The conversion may fail due to the invalid or unsupported syntax of the input URI.

Parameters:
pszUri - the input URI string
strFileName - on return, the file path string obtained as the result of conversion; unspecified if conversion failed
Returns:
true if conversion was successful; false if conversion failed

Unicorn XML Toolkit
Version 1.50.00


This document was created using Unicorn DOC++.

Copyright 1999-2001 Unicorn Enterprises SA.
All Rights Reserved.