Google APIs Client Library for C++
UriTemplate Class Reference

Provides the ability to produce concrete URLs from templated ones. More...

#include "client/util/uri_template.h"

List of all members.

Public Types

typedef ResultCallback3
< util::Status, const
StringPiece &, const
UriTemplateConfig &, string * > 
AppendVariableCallback
 Serves as a helper function for supplying variable values.

Static Public Member Functions

static util::Status Expand (const StringPiece &uri, AppendVariableCallback *supplier, string *target)
 Expand variables without collecting their names.
static util::Status Expand (const StringPiece &uri, AppendVariableCallback *supplier, string *target, set< StringPiece > *found_parameters)
 Expand variables.
static void AppendListFirst (const StringPiece &value, const UriTemplateConfig &config, string *target)
 Appends the first value of a list.
static void AppendListNext (const StringPiece &value, const UriTemplateConfig &config, string *target)
 Appends the value of a list, other than the first.
static void AppendMapFirst (const StringPiece &key, const StringPiece &value, const UriTemplateConfig &config, string *target)
 Appends the first key,value pair of a map.
static void AppendMapNext (const StringPiece &key, const StringPiece &value, const UriTemplateConfig &config, string *target)
 Appends a key,value pair of a map, other than the first.

Detailed Description

Provides the ability to produce concrete URLs from templated ones.

The UriTemplate class produces concrete URLs required to make HTTP invocations from the templated URIs following the RFC 6570 URI Template standard commonly used by REST services on the Google Cloud Platform.

This class is a collection of static methods that build up the URL from a URI template by calling an AppendVariableCallback to resolve the templated variables that it encounters.

The callback is always a repeatable one created with NewPermanentCallback.

See also:
NewPermanentCallback
Expand

Member Typedef Documentation

typedef ResultCallback3< util::Status, const StringPiece&, const UriTemplateConfig&, string*> AppendVariableCallback

Serves as a helper function for supplying variable values.

This callback should call the appropriate Append* methods with the value and target string. If the value is a map or list then also pass the opaque UriTemplateConfig parameter.

If the variable is a list of map then the callback should use the Append*First method to add the first element (if any) then call Append*Next for each of the remaining elements (if any).

Parameters:
[in]StringPieceThe name of the variable to append.
[in]UriTemplateConfigOpaque pass through argument.
[in,out]Thetarget string to append to
Returns:
success if the variabel coudl be resolved, or failure if not.

Member Function Documentation

static void AppendListFirst ( const StringPiece &  value,
const UriTemplateConfig &  config,
string *  target 
) [static]

Appends the first value of a list.

This method is intended to support AppendVariableCallback.

Parameters:
[in]valueThe first value.
[in]configThe opaque passthrough parameter from the AppendVariableCallback.
[in,out]targetThe string to append the value to.
static void AppendListNext ( const StringPiece &  value,
const UriTemplateConfig &  config,
string *  target 
) [static]

Appends the value of a list, other than the first.

This method is intended to support AppendVariableCallback.

Parameters:
[in]valueThe element value to append.
[in]configThe opaque passthrough parameter from the AppendVariableCallback.
[in,out]targetThe string to append the value to.
static void AppendMapFirst ( const StringPiece &  key,
const StringPiece &  value,
const UriTemplateConfig &  config,
string *  target 
) [static]

Appends the first key,value pair of a map.

This method is intended to support AppendVariableCallback.

Parameters:
[in]keyThe first key.
[in]valueThe value of the first key.
[in]configThe opaque passthrough parameter from the AppendVariableCallback.
[in,out]targetThe string to append the value to.
static void AppendMapNext ( const StringPiece &  key,
const StringPiece &  value,
const UriTemplateConfig &  config,
string *  target 
) [static]

Appends a key,value pair of a map, other than the first.

This method is intended to support AppendVariableCallback.

Parameters:
[in]keyThe element's key to append.
[in]valueThe value of the key.
[in]configThe opaque passthrough parameter from the AppendVariableCallback.
[in,out]targetThe string to append the value to.
static util::Status Expand ( const StringPiece &  uri,
AppendVariableCallback supplier,
string *  target 
) [inline, static]

Expand variables without collecting their names.

Parameters:
[in]uriThe templated uri to expand.
[in]supplierThe callback that supplies variable values.
[out]targetThe string to resolve the templated uri into.
Returns:
success if all the variables found could be resolved. failure if some unresovled variables still remain in the target string.
static util::Status Expand ( const StringPiece &  uri,
AppendVariableCallback supplier,
string *  target,
set< StringPiece > *  found_parameters 
) [static]

Expand variables.

Parameters:
[in]uriThe templated uri to expand.
[in]supplierThe callback that supplies variable values.
[out]targetThe string to resolve the templated uri into.
[out]found_parametersPopulated with the list of parameter names that were resolved while expanding the uri. NULL is permitted if the caller does not wish to collect these.
Returns:
success if all the variables found could be resolved. failure if some unresovled variables still remain in the target string.

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