HGL::Common::URI Class Reference
[Utility classes]
Class to access files locally and remote.
More...
#include <uri.h>
Inherits std::istream.
List of all members.
Public Types |
|
typedef std::set< std::string > | PROTOCOLS |
| | Set of supported protocols.
|
Public Member Functions |
| | URI (const char *const uri, const char *const mode) throw (HGL::Exception::IOException) |
| | Constructor
|
| | URI (const char *const uri) throw (HGL::Exception::IOException) |
| | Constructor
|
| std::string | getProtocol () const |
| | Gets the protocol.
|
| __off_t | getSize () const throw (HGL::Exception::IOException) |
| | Gets the size in bytes of the file.
|
| std::string | getURI () const |
| | Gets the URI.
|
| bool | isStdin () const |
| | Checks if this URI is attached to standard input.
|
| | operator FILE * () const throw (HGL::Exception::IOException) |
| | Gets the FILE file descriptor of the file.
|
| void | operator>> (std::string &s) const throw (HGL::Exception::IOException) |
| | Reads the entire file into a std::string.
|
| | throw (HGL::Exception::IOException) |
| | Constructor
|
Static Public Member Functions |
| static const PROTOCOLS | getProtocols () |
| | Gets a set of all supported protocols.
|
| static bool | isRemote (const std::string &uri) |
| | Checks if the URI is a remote URI.
|
| static void | prefetch (const std::string &uri, const char *const mode) |
| | Tries to prefetch a remote URL in background.
|
| static void | pushSearchPath (const std::string &searchPath, bool front=false) |
| | Pushes a path to the directories to prepend if the file is not found.
|
Static Public Attributes |
|
static URI | STDIN |
| | an URI which points to stdin
|
Detailed Description
Class to access files locally and remote.
This class handles the access of local files as well as remote files and from the standard input.
Since version 0.5.18 it implements std::istream and therefore can be used as input stream as well.
- Author:
- Heiko Schäfer <heiko@hgl.rangun.de>
Constructor & Destructor Documentation
Constructor
Creates an URI with open mode "r"
- Parameters:
-
Constructor
- Parameters:
-
| uri | URI to open |
| mode | open mode, i.e. "r" or "rb" |
Member Function Documentation
| std::string URI::getProtocol |
( |
|
) |
const |
Gets the protocol.
- Returns:
- the protocol
Gets a set of all supported protocols.
- Returns:
- a set of all supported protocols
Gets the size in bytes of the file.
- Returns:
- the size in bytes
| std::string URI::getURI |
( |
|
) |
const |
| bool URI::isRemote |
( |
const std::string & |
uri |
) |
[static] |
Checks if the URI is a remote URI.
- Parameters:
-
- Returns:
true, if the URI is remote, false otherwise
| bool URI::isStdin |
( |
|
) |
const |
Checks if this URI is attached to standard input.
- Returns:
true if attached to standard input, false otherwise
- Since:
- 0.5.18
Gets the FILE file descriptor of the file.
- Returns:
- the
FILE file descriptor
Reads the entire file into a std::string.
- Parameters:
-
| s | the std::string to read the entire file in |
| void URI::prefetch |
( |
const std::string & |
uri, |
|
|
const char *const |
mode | |
|
) |
| | [static] |
Tries to prefetch a remote URL in background.
If the file could be prefetches successfully, subsequent access to it won't be downloaded again, but the locally downloaded copy is accessed.
- Parameters:
-
| uri | the URI to prefetch |
| mode | open mode, i.e. "r" or "rb" |
| void URI::pushSearchPath |
( |
const std::string & |
searchPath, |
|
|
bool |
front = false | |
|
) |
| | [static] |
Pushes a path to the directories to prepend if the file is not found.
- Note:
- this works only for relative paths
- Parameters:
-
| searchPath | the path to push to the serach patch list |
| front | if true, the path gets prepended as first search element |
Constructor
- Parameters:
-
| uri | URI to open |
| mode | open mode, i.e. "r" or "rb" |