Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

Doc2 Class Reference

A class to contain document references. More...

List of all members.


Public Methods

 Doc2 (const std::string &url=std::string(), const Doc2 *relative=0)
 Constructor.

 ~Doc2 ()
 Destructor.

void seturl (const std::string &url, const Doc2 *relative=0)
 Set the URL.

const std::string url () const
 Get the URL.

const std::string urlBase () const
 Get the portion of the path likely to correspond to a file name without its extension.

const std::string urlExt () const
 Get the portion of the path likely to correspond to a file name extension.

const std::string urlPath () const
 Get the URL without the last component of the path.

const std::string urlProtocol () const
 Get the URL scheme.

const std::string urlModifier () const
 Get the fragment identifier.

const char * localName ()
 Get the fully qualified name of a local file that is the downloaded resource at d_url.

const char * localPath ()
 Get the path of the local file that is the downloaded resource at d_url.

std::istream & inputStream ()
 Get an input stream for the resource.

std::ostream & outputStream ()
 Get an output stream for the resource.


Private Methods

 Doc2 (const Doc2 &)
Doc2 & operator= (const Doc2 &)
bool filename (char *fn, int nfn)
 Converts a url into a local filename.


Private Attributes

std::string url_
 The URL.

char * tmpfile_
 Name of the temporary file created for the local copy of the resource.

std::istream * istm_
 A file descriptor for reading the local copy of the resource.

std::ostream * ostm_
 A pointer to a std::ostream used for writing the resource.


Detailed Description

A class to contain document references.

Doc2 is a hack of Doc. When the ANTLR parser was added to OpenVRML, a Doc work-alike was needed that would read from a std::istream instead of a C FILE *. Doc2's purpose is to fill that need, and to remind us through its ugliness just how badly both it and Doc need to be replaced with an I/O solution that doesn't suck.


Constructor & Destructor Documentation

Doc2 const std::string &    url = std::string(),
const Doc2 *    relative = 0
[explicit]
 

Constructor.

Parameters:
url an HTTP or file URL.
relative the Doc2 that url is relative to, or 0 if url is an absolute URL.

~Doc2  
 

Destructor.


Member Function Documentation

bool filename char *    fn,
int    nfn
[private]
 

Converts a url into a local filename.

Return values:
fn a character buffer to hold the local filename.
Parameters:
nfn the number of elements in the buffer fn points to.

std::istream & inputStream  
 

Get an input stream for the resource.

Returns:
an input stream for the resource.

const char * localName  
 

Get the fully qualified name of a local file that is the downloaded resource at d_url.

Returns:
the fully qualified name of a local file that is the downloaded resource at d_url.

const char * localPath  
 

Get the path of the local file that is the downloaded resource at d_url.

Returns:
the path of the local file that is the downloaded resource at d_url.

std::ostream & outputStream  
 

Get an output stream for the resource.

Returns:
an output stream for the resource.

void seturl const std::string &    url,
const Doc2 *    relative = 0
 

Set the URL.

Parameters:
url the new URL.
relative the Doc2 that url is relative to, or 0 if url is an absolute URL.

const std::string url   const
 

Get the URL.

Returns:
the URL.

const std::string urlBase   const
 

Get the portion of the path likely to correspond to a file name without its extension.

Returns:
the portion of the last path element preceding the last '.' in the path, or an empty string if the last path element is empty.

const std::string urlExt   const
 

Get the portion of the path likely to correspond to a file name extension.

Returns:
the portion of the last path element succeeding the last '.' in the path, or an empty string if the last path element includes no '.'.

const std::string urlModifier   const
 

Get the fragment identifier.

Returns:
the fragment identifier, including the leading '#', or an empty string if there is no fragment identifier.

const std::string urlPath   const
 

Get the URL without the last component of the path.

In spite of its name, this method does not return the URL's path.

Returns:
the portion of the URL including the scheme, the authority, and all but the last component of the path.

const std::string urlProtocol   const
 

Get the URL scheme.

Returns:
the URL scheme.

Member Data Documentation

std::istream * istm_ [private]
 

A file descriptor for reading the local copy of the resource.

std::ostream * ostm_ [private]
 

A pointer to a std::ostream used for writing the resource.

char * tmpfile_ [private]
 

Name of the temporary file created for the local copy of the resource.

char * url_ [private]
 

The URL.