rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

List of all members | Public Types | Public Member Functions
IlIUrlStream Class Reference

Input stream class. More...

#include <ilog/iurlstr.h>

Inherits IL_STDPREF istream.

Public Types

enum  StreamHint { Normal, NoRandomAccess }
 This enumeration defines the possible values for the hint. More...
 

Public Member Functions

 IlIUrlStream (const char *name, IlBoolean binary=IlFalse)
 Constructor. More...
 
IlUInt getBufferLimit () const
 Returns the size limit of the internal buffer. More...
 
const char * getHeader () const
 Retrieves the header of the remote host response. More...
 
StreamHint getHints () const
 Returns the hints of the stream. More...
 
void setBufferLimit (IlUInt sizelimit)
 Sets the size limit of the internal buffer. More...
 
void setHints (StreamHint hints)
 Sets the hints for this instance. More...
 

Detailed Description

Input stream class.

Library: ilog

IlIUrlStream is a subclass of the standard C++ class istream that makes it possible for you to access remote files, through usual Internet protocols, and decompress (on the fly) streams that are compressed with the gzip or zip compress utilities.

Instead of creating your stream using a path name, you can provide (in the constructor) a complete and valid URL (Uniform Resource Locator), which is a string that has the following form:

[protocol:][//[user:passwd@]host[:port]]pathname

This indicates that you want to access a path called pathname on the remote host host using the transfer protocol protocol, and the port number port. Some protocols and servers require that you provide a login name and a password; you can specify those in the fields user and password.

Supported protocols are ftp, http, and file. Note that you need to provide a login name and a password when using the ftp protocol.

The API for this class is exactly the same as the istream's, so you can simply replace istream by IlIUrlStream in your code to be able to access remote files.

Member Enumeration Documentation

This enumeration defines the possible values for the hint.

Enumerator
Normal 

No particular hint.

NoRandomAccess 

The stream does not need random access. This allows not to buffer the whole stream in memory.

Constructor & Destructor Documentation

IlIUrlStream::IlIUrlStream ( const char *  name,
IlBoolean  binary = IlFalse 
)

Constructor.

The constructor initializes this stream by opening the indicated URL for reading. Just as in the regular ifstream class, you must check that the access has succeeded.

Parameters
urlThe URL to be opened. If no protocol is specified (that is, this string does not start with a xxx: pattern), then a regular file is opened. This makes the replacement of all ifstreams by IlIUrlStreams seamless.
binaryIf set to IlTrue, indicates that the file should be opened in binary mode. The default opens the file in text mode for reading (ios::in), but if you are running a Windows machine, you may consider setting the 'binary' flag to IlTrue to read binary data.

Member Function Documentation

IlUInt IlIUrlStream::getBufferLimit ( ) const

Returns the size limit of the internal buffer.

Returns
The size limit of the internal buffer.
const char* IlIUrlStream::getHeader ( ) const

Retrieves the header of the remote host response.

In the case of a file read through http, the header usually contains information on the file size and dates.

Returns
The http header as returned by the remote host. You must not modify or delete the returned string.
StreamHint IlIUrlStream::getHints ( ) const

Returns the hints of the stream.

Returns
The hints of the stream.
void IlIUrlStream::setBufferLimit ( IlUInt  sizelimit)

Sets the size limit of the internal buffer.

Parameters
sizelimitThe new size limit.
void IlIUrlStream::setHints ( StreamHint  hints)

Sets the hints for this instance.

Parameters
hintsThe new stream hints.

© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.