osgEarth 2.1.1
Public Types | Public Member Functions | Private Attributes

osgEarth::HTTPRequest Class Reference

List of all members.

Public Types

typedef std::map< std::string,
std::string > 
Parameters

Public Member Functions

 HTTPRequest (const std::string &url)
 HTTPRequest (const HTTPRequest &rhs)
void addParameter (const std::string &name, const std::string &value)
void addParameter (const std::string &name, int value)
void addParameter (const std::string &name, double value)
const ParametersgetParameters () const
std::string getURL () const

Private Attributes

Parameters _parameters
std::string _url

Detailed Description

An HTTP request for use with the HTTPClient class.

Definition at line 73 of file HTTPClient.


Member Typedef Documentation

typedef std::map<std::string,std::string> osgEarth::HTTPRequest::Parameters

Definition at line 87 of file HTTPClient.


Constructor & Destructor Documentation

HTTPRequest::HTTPRequest ( const std::string &  url)

Constructs a new HTTP request that will acces the specified base URL.

Definition at line 117 of file HTTPClient.cpp.

: _url( url )
{
    //NOP
}
HTTPRequest::HTTPRequest ( const HTTPRequest rhs)

copy constructor.

Definition at line 123 of file HTTPClient.cpp.

                                                 :
_parameters( rhs._parameters ),
_url( rhs._url )
{
    //nop
}

Member Function Documentation

void HTTPRequest::addParameter ( const std::string &  name,
const std::string &  value 
)

Adds an HTTP parameter to the request query string.

Definition at line 131 of file HTTPClient.cpp.

{
    _parameters[name] = value;
}

Here is the caller graph for this function:

void HTTPRequest::addParameter ( const std::string &  name,
int  value 
)

Definition at line 137 of file HTTPClient.cpp.

{
    std::stringstream buf;
    buf << value;
        std::string bufStr;
    bufStr = buf.str();
    _parameters[name] = bufStr;
}
void HTTPRequest::addParameter ( const std::string &  name,
double  value 
)

Definition at line 147 of file HTTPClient.cpp.

{
    std::stringstream buf;
    buf << value;
        std::string bufStr;
    bufStr = buf.str();
    _parameters[name] = bufStr;
}
const HTTPRequest::Parameters & HTTPRequest::getParameters ( ) const

Ready-only access to the parameter list (as built with addParameter)

Definition at line 157 of file HTTPClient.cpp.

{
    return _parameters; 
}
std::string HTTPRequest::getURL ( ) const

Gets a copy of the complete URL (base URL + query string) for this request

Definition at line 163 of file HTTPClient.cpp.

{
    if ( _parameters.size() == 0 )
    {
        return _url;
    }
    else
    {
        std::stringstream buf;
        buf << _url;
        for( Parameters::const_iterator i = _parameters.begin(); i != _parameters.end(); i++ )
        {
            buf << ( i == _parameters.begin() && _url.find( "?" ) == std::string::npos? "?" : "&" );
            buf << i->first << "=" << i->second;
        }
                std::string bufStr;
                bufStr = buf.str();
        return bufStr;
    }
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 96 of file HTTPClient.

std::string osgEarth::HTTPRequest::_url [private]

Definition at line 97 of file HTTPClient.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines