latest version v1.9 - last update 10 Apr 2010 |
This is an abstract base class for handling a kind of data service. More...
#include <ltiURL.h>
Public Member Functions | |
virtual bool | getDate (std::string &date)=0 |
virtual bool | getContentType (std::string &type)=0 |
virtual bool | getContentLength (int &size)=0 |
virtual bool | getDataStream (std::ifstream *&i)=0 |
const char * | getStatusString () const |
bool | isOk () |
Protected Member Functions | |
serviceHandler (url &u) | |
std::ifstream * | getIn () |
std::ofstream * | getOut () |
SOCKET | getSocket () |
void | setStatusString (const char *msg, const char *msg2=0) |
This is an abstract base class for handling a kind of data service.
It contains methods for initiating a connection given an url and get the most important meta data. A certain service handler is created by subclassing this class. At present, there is only a HTTP handler which is buried in the implementation.
lti::url::serviceHandler::serviceHandler | ( | url & | u | ) | [protected] |
Constructor.
Subclasses must call this constructor in order to set the URL for which this handler is used.
virtual bool lti::url::serviceHandler::getContentLength | ( | int & | size | ) | [pure virtual] |
Gets the length of the document which is described by the URL.
size | will receive the size of the document in bytes. If this value is below zero, it means that the size is unknown. |
virtual bool lti::url::serviceHandler::getContentType | ( | std::string & | type | ) | [pure virtual] |
Gets the MIME type description of the document which is described by the URL.
type | will receive the type description in standard MIME notation |
virtual bool lti::url::serviceHandler::getDataStream | ( | std::ifstream *& | i | ) | [pure virtual] |
Gets a pointer to an input stream which can be used for retrieving the data.
virtual bool lti::url::serviceHandler::getDate | ( | std::string & | date | ) | [pure virtual] |
Gets the date of the server reply, may be empty.
date | will receive the date in standard ASCII notation |
std::ifstream* lti::url::serviceHandler::getIn | ( | ) | [inline, protected] |
Returns the input stream for the URL which is handled by this object.
std::ofstream* lti::url::serviceHandler::getOut | ( | ) | [inline, protected] |
Returns the output stream for the URL which is handled by this object.
SOCKET lti::url::serviceHandler::getSocket | ( | ) | [inline, protected] |
Returns the socket used to send/receive bytes (only for windows).
const char* lti::url::serviceHandler::getStatusString | ( | ) | const |
return the last message set with setStatusString().
This will never return 0. If no status-string has been set yet an empty string (pointer to a string with only the char(0)) will be returned.
bool lti::url::serviceHandler::isOk | ( | ) | [inline] |
Returns true if the handler's state is in order and meta-data can be inquired.
void lti::url::serviceHandler::setStatusString | ( | const char * | msg, | |
const char * | msg2 = 0 | |||
) | [protected] |
set a status string.
msg | the const string to be reported next time by getStatusString(). The given string will be copied. This message will be usually set within the apply methods to indicate an error cause. | |
msg2 | another message string, which is simply appended to the first one. |