Home | Download | Screen shots | Discussion | Documentation
--- | --- | --- | --- | ---

Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

# openvrml::doc2 Class Reference

List of all members.

## 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.

## Public Member Functions

| 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 | url_base () const
| Get the portion of the path likely to correspond to a file name without its extension.
const std::string | url_ext () const
| Get the portion of the path likely to correspond to a file name extension.
const std::string | url_path () const
| Get the URL without the last component of the path.
const std::string | url_protocol () const
| Get the URL scheme.
const std::string | url_modifier () const
| Get the fragment identifier.
const char * | local_name ()
| Get the fully qualified name of a local file that is the downloaded resource at url_.
const char * | local_path ()
| Get the path of the local file that is the downloaded resource at url_.
std::istream & | input_stream ()
| Get an input stream for the resource.
std::ostream & | output_stream ()
| Get an output stream for the resource.

## Private Member Functions

bool | filename (char *fn, size_t 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.

## Constructor & Destructor Documentation

openvrml::doc2::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.

openvrml::doc2::~doc2 | ( |  | ) |

| Destructor.

## Member Function Documentation

void openvrml::doc2::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 openvrml::doc2::url | ( |  | ) | const

Get the URL.

Returns:
  the URL.

const std::string openvrml::doc2::url_base | ( |  | ) | 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 openvrml::doc2::url_ext | ( |  | ) | 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 openvrml::doc2::url_path | ( |  | ) | 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 openvrml::doc2::url_protocol | ( |  | ) | const

Get the URL scheme.

Returns:
  the URL scheme.

const std::string openvrml::doc2::url_modifier | ( |  | ) | const

Get the fragment identifier.

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

const char * openvrml::doc2::local_name | ( |  | ) |

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

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

const char * openvrml::doc2::local_path | ( |  | ) |

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

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

std::istream & openvrml::doc2::input_stream | ( |  | ) |

Get an input stream for the resource.

Returns:
  an input stream for the resource.

std::ostream & openvrml::doc2::output_stream | ( |  | ) |

Get an output stream for the resource.

Returns:
  an output stream for the resource.

bool openvrml::doc2::filename | ( | char * | fn,
|  | size_t | 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.

## Member Data Documentation

char * openvrml::doc2::url_`[private]`

| The URL.

char * openvrml::doc2::tmpfile_`[private]`

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

std::istream * openvrml::doc2::istm_`[private]`

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

std::ostream * openvrml::doc2::ostm_`[private]`

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