Public Types | Public Member Functions | Friends

atscppapi::Headers Class Reference

Encapsulates the headers portion of a request or response. More...

#include <Headers.h>

Inherits atscppapi::noncopyable.

Collaboration diagram for atscppapi::Headers:
Collaboration graph
[legend]

Public Types

typedef unsigned int size_type
typedef header_field_iterator iterator

Public Member Functions

 Headers ()
 Constructor for Headers.
 Headers (void *bufp, void *mloc)
 Constructor for Headers, this shouldn't be used directly unless you're trying to mix the C++ and C apis.
void reset (void *bufp, void *mloc)
 Context Values are a way to share data between plugins, the key is always a string and the value can be a shared_ptr to any type that extends ContextValue.
bool isInitialized () const
 Check if the header class has been initialized.
bool empty ()
 Check if the headers are empty.
size_type size () const
 Get the size of the headers (the number of HeaderFields).
size_type lengthBytes () const
 Get the size of the headers (the number of HeaderFields).
iterator begin ()
 Returns an iterator to the start of the HeaderFields.
iterator end ()
 Returns an iterator to the end of the HeaderFields (beyond the last element).
bool clear ()
 Clears all headers.
bool erase (iterator it)
 Erase a single header field pointed to by an iterator.
size_type erase (const std::string &key)
 Erase all headers whose name matches key (this is a case insensitive match).
size_type erase (const char *key, int length=-1)
 Erase all headers whose name matches key (this is a case insensitive match).
size_type count (const char *key, int length=-1)
 Count all headers whose name matches key (this is a case insensitive match).
size_type count (const std::string &key)
 Count all headers whose name matches key (this is a case insensitive match).
std::string values (const std::string &key, const char *join=",")
 Join all headers whos name is key with the optionally specified join string.
std::string values (const std::string &key, const std::string &join)
 Join all headers whos name is key with the optionally specified join string.
std::string values (const std::string &key, const char join)
 Join all headers whos name is key with the optionally specified join character.
std::string value (const std::string key, size_type index=0)
 Returns the value at given position of header with given name.
iterator find (const std::string &key)
 Returns an iterator to the first HeaderField with the name key.
iterator find (const char *key, int length=-1)
 Returns an iterator to the first HeaderField with the name key.
iterator append (const std::string &key, const std::string &value)
 Append a HeaderField.
iterator set (const std::string &key, const std::string &value)
 Erase all headers with name specified by key and then re-create the header with the specified values.
HeaderField operator[] (const std::string &key)
 Set the header field values to the value given, the header field will be created if it does not already exist.
std::string str ()
 Get a human-readable/log-friendly string representing all the header fields.
std::string wireStr ()
 Get a string that can be put on the wire.
 ~Headers ()

Friends

class Request
class ClientRequest
class Response
std::ostream & operator<< (std::ostream &os, Headers &obj)

Detailed Description

Encapsulates the headers portion of a request or response.

Definition at line 396 of file Headers.h.


Member Typedef Documentation

Definition at line 428 of file Headers.h.

typedef unsigned int atscppapi::Headers::size_type

Definition at line 427 of file Headers.h.


Constructor & Destructor Documentation

atscppapi::Headers::Headers (  ) 

Constructor for Headers.

This creates a "detached" headers, i.e., not tied to any transaction.

atscppapi::Headers::Headers ( void *  bufp,
void *  mloc 
)

Constructor for Headers, this shouldn't be used directly unless you're trying to mix the C++ and C apis.

Parameters:
bufp the TSMBuffer associated with the headers
mloc the TSMLoc associated with the headers.
Warning:
This should only be used if you're mixing the C++ and C apis, it will be constructed automatically if using only the C++ api.
atscppapi::Headers::~Headers (  ) 

Member Function Documentation

iterator atscppapi::Headers::append ( const std::string &  key,
const std::string &  value 
)

Append a HeaderField.

Parameters:
key the name of the header field to append
value the value of the header field to append
Returns:
an iterator to the appended header field or the end() iterator if append fails.
iterator atscppapi::Headers::begin (  ) 

Returns an iterator to the start of the HeaderFields.

Returns:
an iterator point to the start of the header fields.
bool atscppapi::Headers::clear (  ) 

Clears all headers.

Returns:
true if the headers were succesfully cleared.
size_type atscppapi::Headers::count ( const char *  key,
int  length = -1 
)

Count all headers whose name matches key (this is a case insensitive match).

Parameters:
the name of the header fields to erase
the length of the key (optional).
Returns:
the number of elements erased that matched the key
size_type atscppapi::Headers::count ( const std::string &  key  ) 

Count all headers whose name matches key (this is a case insensitive match).

Parameters:
the name of the header fields to count
Returns:
the number of elements whose name is key.
bool atscppapi::Headers::empty (  ) 

Check if the headers are empty.

Returns:
a boolean value representing whether or not the Headers are empty
iterator atscppapi::Headers::end (  ) 

Returns an iterator to the end of the HeaderFields (beyond the last element).

Returns:
an iterator that points beyond the last element in the header fields.
bool atscppapi::Headers::erase ( iterator  it  ) 

Erase a single header field pointed to by an iterator.

Parameters:
an iterator pointing to a header field.
Returns:
true if the header field pointed to by the iterator was erased.
size_type atscppapi::Headers::erase ( const std::string &  key  ) 

Erase all headers whose name matches key (this is a case insensitive match).

Parameters:
the name of the header fields to erase
Returns:
the number of elements erased that matched the key
size_type atscppapi::Headers::erase ( const char *  key,
int  length = -1 
)

Erase all headers whose name matches key (this is a case insensitive match).

Parameters:
the name of the header fields to erase
the length of the key (optional).
Returns:
the number of elements erased that matched the key
iterator atscppapi::Headers::find ( const std::string &  key  ) 

Returns an iterator to the first HeaderField with the name key.

Parameters:
key the name of first header field ot find.
Returns:
an iterator that points to the first matching header field with name key.
iterator atscppapi::Headers::find ( const char *  key,
int  length = -1 
)

Returns an iterator to the first HeaderField with the name key.

Parameters:
key the name of first header field ot find.
the length of the key specified (optional).
Returns:
an iterator that points to the first matching header field with name key.
bool atscppapi::Headers::isInitialized (  )  const

Check if the header class has been initialized.

If you're only using the C++ api then this should always return true.

Returns:
a boolean value representing whether or not the Headers have been initialized..
size_type atscppapi::Headers::lengthBytes (  )  const

Get the size of the headers (the number of HeaderFields).

Returns:
the number of HeaderFields
HeaderField atscppapi::Headers::operator[] ( const std::string &  key  ) 

Set the header field values to the value given, the header field will be created if it does not already exist.

Parameters:
key the name of the header field whose value to set.
Returns:
an iterator to the new header field or the end() iterator if append fails.
Warning:
This will create a header field with the given name, thus it should not be used to check for the existance of a header, use count() or find() instead.
void atscppapi::Headers::reset ( void *  bufp,
void *  mloc 
)

Context Values are a way to share data between plugins, the key is always a string and the value can be a shared_ptr to any type that extends ContextValue.

Parameters:
bufp the TSMBuffer associated with the headers
mloc the TSMLoc associated with the headers.
Warning:
This should only be used if you're mixing the C++ and C apis.
iterator atscppapi::Headers::set ( const std::string &  key,
const std::string &  value 
)

Erase all headers with name specified by key and then re-create the header with the specified values.

Parameters:
key the name of the header field to erased and re-created.
value the value of the header field to set.
Returns:
an iterator to the new header field or the end() iterator if append fails.
size_type atscppapi::Headers::size (  )  const

Get the size of the headers (the number of HeaderFields).

Returns:
the number of HeaderFields
std::string atscppapi::Headers::str (  ) 

Get a human-readable/log-friendly string representing all the header fields.

Returns:
a string representation of all the header fields
std::string atscppapi::Headers::value ( const std::string  key,
size_type  index = 0 
)

Returns the value at given position of header with given name.

Parameters:
name of header
position of value
Returns:
value
std::string atscppapi::Headers::values ( const std::string &  key,
const char *  join = "," 
)

Join all headers whos name is key with the optionally specified join string.

Parameters:
the name of the headers to join into a single string
an optional join string (defaults to ",")
Returns:
a string which is all of the joined values of headers matching key.
std::string atscppapi::Headers::values ( const std::string &  key,
const std::string &  join 
)

Join all headers whos name is key with the optionally specified join string.

Parameters:
the name of the headers to join into a single string
the string to join the fields with
Returns:
a string which is all of the joined values of headers matching key.
std::string atscppapi::Headers::values ( const std::string &  key,
const char  join 
)

Join all headers whos name is key with the optionally specified join character.

Parameters:
the name of the headers to join into a single string
the join character.
Returns:
a string which is all of the joined values of headers matching key.
std::string atscppapi::Headers::wireStr (  ) 

Get a string that can be put on the wire.

Returns:
a string representation of all the header fields

Friends And Related Function Documentation

friend class ClientRequest [friend]

Definition at line 594 of file Headers.h.

std::ostream& operator<< ( std::ostream &  os,
Headers obj 
) [friend]
friend class Request [friend]

Definition at line 593 of file Headers.h.

friend class Response [friend]

Definition at line 595 of file Headers.h.


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