![]() |
latest version v1.9 - last update 10 Apr 2010 |
![]() |
Class for retrieving documents identified by an URL. More...
#include <ltiURL.h>
Classes | |
class | parameters |
parameters for the url-object More... | |
class | serviceHandler |
This is an abstract base class for handling a kind of data service. More... | |
class | urlFields |
This class is used to split a URL into its separate fields. More... | |
Public Types | |
enum | serviceType |
enum | dataType |
Public Member Functions | |
url (const std::string &n) | |
~url () | |
bool | isOk () |
virtual bool | setParameters (const parameters &theParam) |
const parameters & | getParameters () const |
bool | get (std::string &data) |
bool | get (vector< ubyte > &data) |
bool | get (ioObject &data, dataType fmt) |
bool | getPNGImage (image &data) |
bool | getJPGImage (image &data) |
bool | getBMPImage (image &data) |
bool | put (const std::string &data) |
bool | put (const vector< ubyte > &data) |
bool | put (const ioObject &data, dataType fmt) |
bool | putPNGImage (const image &data) |
std::istream & | getInputStream () |
std::ostream & | getOutputStream () |
const std::string & | getPath () const |
const char * | getStatusString () const |
Protected Member Functions | |
void | setStatusString (const char *msg, const char *msg2=0) |
Class for retrieving documents identified by an URL.
You simply give it an URL and call the appropriate get method (PUT's are not yet supported. For instance:
lti::url doc("http://tintas/axiom/axicon.png"); if (doc.isOk()) { doc.getPNGImage(tmp); viewer view; view.show(tmp); getchar(); } else { std::cerr << doc.getStatusString() << std::endl; }
Unfortunately, I have no idea how to implement http client code for Windows. Therefore, this class currently only exists for libs compiled for Linux.
Ws2_32.lib is linked (you may need to specify its library in Project..Settings..Link..Object/Library Modules.)
enum lti::url::dataType |
The kind of data type that is expected for reading and writing ioObjects.
The type of service that is associated with the URL.
lti::url::url | ( | const std::string & | n | ) |
Constructor.
Creates a new connection to the URL given as argument. If the connection could be created, the function isOk returns true. Otherwise, it returns false. If the connection failed, the cause can be inquired by calling getStatusString.
lti::url::~url | ( | ) |
Destructor.
Closes the network connection and deletes all allocated data structures.
Retrieves the URL as binary Data written in data.
bool lti::url::get | ( | std::string & | data | ) |
Retrieves the URL as text document.
This only works if the document is of MIME type "text/...".
bool lti::url::getBMPImage | ( | image & | data | ) |
Retrieves the URL as binary Data written in data.
std::istream& lti::url::getInputStream | ( | ) |
Returns the input stream that is used for reading the document.
(linux only)
bool lti::url::getJPGImage | ( | image & | data | ) |
Retrieves the URL as binary Data written in data.
std::ostream& lti::url::getOutputStream | ( | ) |
Returns the output stream that is used for writing the document.
(linux only)
const parameters& lti::url::getParameters | ( | ) | const |
returns the current parameters
const std::string& lti::url::getPath | ( | ) | const |
Returns the path component of this URL.
bool lti::url::getPNGImage | ( | image & | data | ) |
Retrieves the URL as binary Data written in data.
const char* lti::url::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::isOk | ( | ) |
Returns true if so far all operations have been successful.
bool lti::url::put | ( | const std::string & | data | ) |
Not implemented yet.
bool lti::url::putPNGImage | ( | const image & | data | ) |
Not implemented yet.
virtual bool lti::url::setParameters | ( | const parameters & | theParam | ) | [virtual] |
set url's parameters.
This member makes a copy of theParam: the url will keep its own copy of the parameters!
void lti::url::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. |