Rudiments
|
#include <mvc.h>
Inherits object.
The mvcresult class provides an object to which "results" can be attached and passed up from the DAO tier to other MVC tiers.
In the Rudiments MVC framework, collections (lists, dictionaries, trees, scalars, doms, etc.) are passed around between tiers instead of DTOs and/or domain objects. mvcresult objects provide a convenient object to attach collections to, as well as status, status codes and status messages.
Internally, each instance of mvcresult has:
status - true if the operation succeeded, and false if it failed status code - a specific success or error code status message - a specific success or error message data - a dictionary where each key is a string and each value is a collection wastebasket - an instance of the wastebasked class to which parent obejcts of the collections, or of members of the collections can be attached for future disposal
mvcresult::mvcresult | ( | ) |
Creates an instance of the mvcresult class.
|
virtual |
Deletes this instance of the mvcresult class.
void mvcresult::attachData | ( | const char * | key, |
collection * | data ) |
Associates with collection "data" with string "key".
When using this method, "data" will be deleted when this instance of mvcresult is deleted.
uint32_t mvcresult::getCode | ( | ) |
Returns the status code as set by a previous call to setStatus(), setSuccess(), setFailed(), or setCode().
collection * mvcresult::getData | ( | const char * | key | ) |
Returns the collection associated with "key".
linkedlist< char * > * mvcresult::getKeys | ( | ) |
Returns the list of keys previously associated with collections using setData() or attachData().
Returns the status message as set by a previous call to setStatus(), setSuccess(), setFailed(), or setMessage().
bool mvcresult::getSuccess | ( | ) |
Returns the status as set by a previous call to setStatus(), setSuccess(), setFailed(), or setSuccess().
wastebasket * mvcresult::getWastebasket | ( | ) |
Returns the wastebasket.
void mvcresult::setCode | ( | uint32_t | code | ) |
Sets the status code to "code" but does not change the status or status message.
void mvcresult::setData | ( | const char * | key, |
collection * | data ) |
Associates with collection "data" with string "key".
When using this method, "data" will not be deleted when this instance of mvcresult is deleted.
void mvcresult::setFailed | ( | ) |
Sets the status to false (failure), status code to 0, and status message to NULL.
void mvcresult::setFailed | ( | uint32_t | code | ) |
Sets the status to false (failure), status code to "code", and status message to NULL.
Sets the status to false (failure), status code to "code", and status message to "message".
Sets the status message to "message" but does not change the status or status code.
Sets the status to "success", status code to 0, and status message to NULL.
Sets the status to "success", status code to "code", and status message to NULL.
Sets the status to "success", status code to "code", and status message to "message".
void mvcresult::setSuccess | ( | ) |
Sets the status to true (success), status code to 0, and status message to NULL.
Sets the status "success" but does not change the status code or status message.
void mvcresult::setSuccess | ( | uint32_t | code | ) |
Sets the status to true (success), status code to "code", and status message to NULL.
Sets the status to true (success), status code to "code", and status message to "message".
ssize_t mvcresult::write | ( | ) |
Writes a representation (currently JSON) of the contents of the instance to standard output.
ssize_t mvcresult::write | ( | output * | out | ) |
Writes a representation (currently JSON) of the contents of the instance to "out".
ssize_t mvcresult::writeJson | ( | ) |
Writes an indented JSON representation of the contents of the instance to standard output.
ssize_t mvcresult::writeJson | ( | bool | indent | ) |
Writes a JSON representation of the contents of the instance to standard output.
The representation is indented if "indent" is true and not indented if "indent" is false.
ssize_t mvcresult::writeJson | ( | output * | out | ) |
Writes an indented JSON representation of the contents of the instance to "out".