Parse Arduino Yun SDK  1
Parse Arduino Yun SDK
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
ParseResponse Class Reference

Class that encapsulates Rest API response. This object created indirectly. More...

#include <ParseResponse.h>

Inheritance diagram for ParseResponse:
ParsePush

Public Member Functions

void setBuffer (char *buffer, int size)
 set the customer buffer for writing response data. More...
 
int getErrorCode ()
 get the "error" field in the response. More...
 
int getInt (const char *key)
 get the integer value in the response by key More...
 
double getDouble (const char *key)
 get the double value in the response by key. More...
 
bool getBoolean (const char *key)
 get the boolean value in the response by key More...
 
const char * getString (const char *key)
 get the string value in the response by key More...
 
const char * getJSONBody ()
 get the complete json value of response. More...
 
bool nextObject ()
 ParseQuery ONLY: iterate to next object in query result. More...
 
int count ()
 ParseQuery ONLY: get the count of the objects in query results. More...
 
void close ()
 free resource including system data buffer and client More...
 

Protected Member Functions

void read ()
 
void readWithTimeout (int maxSec)
 
int available ()
 
void freeBuffer ()
 
 ParseResponse (Process *client)
 

Protected Attributes

int bufSize
 
char * buf
 
char * tmpBuf
 
bool isUserBuffer
 
int p = 0
 
int resultCount = -1
 
Process * client
 

Static Protected Attributes

static const int BUFSIZE = 128
 

Friends

class ParseClient
 

Detailed Description

Class that encapsulates Rest API response. This object created indirectly.

Member Function Documentation

void ParseResponse::close ( )

free resource including system data buffer and client

NOTE: the customer buffer will NOT be freed, you need to free them by yourself

int ParseResponse::count ( )

ParseQuery ONLY: get the count of the objects in query results.

NOTE: if the query resutls exceed 2048 bytes(query result buffer size), it will only return the count of objects in the buffer.

Returns
number of objects in the result
bool ParseResponse::getBoolean ( const char *  key)

get the boolean value in the response by key

Parameters
key- key
Returns
the value
double ParseResponse::getDouble ( const char *  key)

get the double value in the response by key.

Parameters
key- key
Returns
the value
int ParseResponse::getErrorCode ( )

get the "error" field in the response.

Returns
error_code when error happens, 0 when there is no error
int ParseResponse::getInt ( const char *  key)

get the integer value in the response by key

Parameters
key- key
Returns
the value
const char * ParseResponse::getJSONBody ( )

get the complete json value of response.

Returns
returned JSON
const char * ParseResponse::getString ( const char *  key)

get the string value in the response by key

Parameters
key- key
Returns
the value
bool ParseResponse::nextObject ( )

ParseQuery ONLY: iterate to next object in query result.

it has to be called before any object opreation(getInt/String/Double) including the first object

Returns
true if successfully iterate to next object false if there is no more object
void ParseResponse::setBuffer ( char *  buffer,
int  size 
)

set the customer buffer for writing response data.

Parameters
buffer- char array buffer
size- size of buffer NOTE: if buffer is not set, a default size of 128 will be initialized.

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