This class provides utility functions to ease the use of Response objects.
More...
#include <ResponseHelper.hpp>
This class provides utility functions to ease the use of Response objects.
- Author
- Adam Fowler adam..nosp@m.fowl.nosp@m.er@ma.nosp@m.rklo.nosp@m.gic.c.nosp@m.om
- Since
- 8.0.2
- Date
- 2016-06-08
- Note
- This class has an external dependency on Microsoft's C++ cpprest API. As this API is required to use MarkLogic's C++ wrapper (this API) , this does not introduce any extra dependencies.
static MLCLIENT_API double mlclient::utilities::ResponseHelper::getAggregateResult |
( |
const Response & |
resp, |
|
|
const std::string & |
aggName |
|
) |
| |
|
static |
Returns a double result from the specified aggregate in the result set.
- Parameters
-
[in] | resp | The Response object |
[in] | aggName | The aggregate name to return (a single response allows multiple to be returned) |
- Returns
- double The double typed aggregate result
static MLCLIENT_API void mlclient::utilities::ResponseHelper::getAggregateResults |
( |
const Response & |
resp, |
|
|
ValuesResult & |
vr |
|
) |
| |
|
static |
Extracts all aggregate results and places them in the provided ValuesResult holder.
- Parameters
-
[in] | resp | The response to parse |
[in,out] | vr | The ValuesResult object to populate |
static MLCLIENT_API void mlclient::utilities::ResponseHelper::getComplexAggregateResults |
( |
const Response & |
resp, |
|
|
ValuesResult & |
vr |
|
) |
| |
|
static |
Extracts all complex aggregate results and places them in the provided ValuesResult holder.
- Note
- UDFs don't just return double values, they can return multiple values, and arrays of them (multiple map:map() objects)
- Parameters
-
[in] | resp | The response to parse |
[in,out] | vr | The ValuesResult object to populate |
static MLCLIENT_API std::string mlclient::utilities::ResponseHelper::getErrorDetailAsString |
( |
const Response & |
resp | ) |
|
|
static |
Returns the full error trace information as a string Throws an exception if the response is not in error.
- Parameters
-
- Returns
- The full error stack as a string, if available
static MLCLIENT_API std::string mlclient::utilities::ResponseHelper::getErrorMessage |
( |
const Response & |
resp | ) |
|
|
static |
Returns the error message of a Response in error Throws an exception if the response is not in error.
- Parameters
-
- Returns
- The string value of the top level error message, if any
static MLCLIENT_API std::vector<std::string> mlclient::utilities::ResponseHelper::getSuggestions |
( |
const Response & |
resp | ) |
|
|
static |
Returns a string list of suggestion values. Used with the response from POST /v1/suggest.
Returns a blank list if the response does not contain suggestions. Throws an exception if response is in error.
- Parameters
-
- Returns
- A list of suggestion values
static MLCLIENT_API bool mlclient::utilities::ResponseHelper::isInError |
( |
const Response & |
resp | ) |
|
|
static |
Returns whether the specified response is a MarkLogic error response.
- Note
- Some MarkLogic error response do NOT return a HTTP 500, so this is an important method to learn!
- Parameters
-
- Returns
- True if the Response is an error response
The documentation for this class was generated from the following file: