LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::url Class Reference

Class for retrieving documents identified by an URL. More...

#include <ltiURL.h>

Inheritance diagram for lti::url:
Inheritance graph
[legend]
Collaboration diagram for lti::url:
Collaboration graph
[legend]

List of all members.

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 parametersgetParameters () 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)

Detailed Description

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


Member Enumeration Documentation

The kind of data type that is expected for reading and writing ioObjects.

The type of service that is associated with the URL.


Constructor & Destructor Documentation

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.


Member Function Documentation

bool lti::url::get ( ioObject data,
dataType  fmt 
)

not implemented yet

bool lti::url::get ( vector< ubyte > &  data  ) 

Retrieves the URL as binary Data written in data.

Returns:
true iff the document could be retrieved successfully.
bool lti::url::get ( std::string &  data  ) 

Retrieves the URL as text document.

This only works if the document is of MIME type "text/...".

Returns:
true iff the document could be retrieved successfully.
bool lti::url::getBMPImage ( image data  ) 

Retrieves the URL as binary Data written in data.

Returns:
true iff the document could be retrieved successfully.
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.

Returns:
true iff the document could be retrieved successfully.
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.

Returns:
true iff the document could be retrieved successfully.
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 ioObject data,
dataType  fmt 
)

Not implemented yet.

bool lti::url::put ( const vector< ubyte > &  data  ) 

Not implemented yet.

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!

Returns:
true if successful, false otherwise
void lti::url::setStatusString ( const char *  msg,
const char *  msg2 = 0 
) [protected]

set a status string.

Parameters:
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.

The documentation for this class was generated from the following file:

Generated on Sat Apr 10 15:28:53 2010 for LTI-Lib by Doxygen 1.6.1