Google APIs Client Library for C++
|
Provides the ability to produce concrete URLs from templated ones. More...
#include "client/util/uri_template.h"
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. |
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.
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).
[in] | StringPiece | The name of the variable to append. |
[in] | UriTemplateConfig | Opaque pass through argument. |
[in,out] | The | target string to append to |
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.
[in] | value | The first value. |
[in] | config | The opaque passthrough parameter from the AppendVariableCallback. |
[in,out] | target | The 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.
[in] | value | The element value to append. |
[in] | config | The opaque passthrough parameter from the AppendVariableCallback. |
[in,out] | target | The 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.
[in] | key | The first key. |
[in] | value | The value of the first key. |
[in] | config | The opaque passthrough parameter from the AppendVariableCallback. |
[in,out] | target | The 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.
[in] | key | The element's key to append. |
[in] | value | The value of the key. |
[in] | config | The opaque passthrough parameter from the AppendVariableCallback. |
[in,out] | target | The 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.
[in] | uri | The templated uri to expand. |
[in] | supplier | The callback that supplies variable values. |
[out] | target | The string to resolve the templated uri into. |
static util::Status Expand | ( | const StringPiece & | uri, |
AppendVariableCallback * | supplier, | ||
string * | target, | ||
set< StringPiece > * | found_parameters | ||
) | [static] |
Expand variables.
[in] | uri | The templated uri to expand. |
[in] | supplier | The callback that supplies variable values. |
[out] | target | The string to resolve the templated uri into. |
[out] | found_parameters | Populated 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. |