Rudiments
Public Member Functions | List of all members
mvcresult Class Reference

Inherits object.

Public Member Functions

 mvcresult ()
 
virtual ~mvcresult ()
 
void setStatus (bool success)
 
void setStatus (bool success, uint32_t code)
 
void setStatus (bool success, uint32_t code, const char *message)
 
void setSuccess ()
 
void setSuccess (uint32_t code)
 
void setSuccess (uint32_t code, const char *message)
 
void setFailed ()
 
void setFailed (uint32_t code)
 
void setFailed (uint32_t code, const char *message)
 
void setSuccess (bool success)
 
bool getSuccess ()
 
void setCode (uint32_t code)
 
uint32_t getCode ()
 
void setMessage (const char *message)
 
const char * getMessage ()
 
void setData (const char *key, collection *data)
 
void attachData (const char *key, collection *data)
 
linkedlist< char * > * getKeys ()
 
collectiongetData (const char *key)
 
ssize_t write ()
 
ssize_t write (output *out)
 
ssize_t writeJson ()
 
ssize_t writeJson (bool indent)
 
ssize_t writeJson (output *out)
 
ssize_t writeJson (output *out, bool indent)
 
wastebasketgetWastebasket ()
 
- Public Member Functions inherited from object
virtual ~object ()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ mvcresult()

mvcresult::mvcresult ( )

Creates an instance of the mvcresult class.

◆ ~mvcresult()

virtual mvcresult::~mvcresult ( )
virtual

Deletes this instance of the mvcresult class.

Member Function Documentation

◆ attachData()

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.

◆ getCode()

uint32_t mvcresult::getCode ( )

Returns the status code as set by a previous call to setStatus(), setSuccess(), setFailed(), or setCode().

◆ getData()

collection* mvcresult::getData ( const char *  key)

Returns the collection associated with "key".

◆ getKeys()

linkedlist<char *>* mvcresult::getKeys ( )

Returns the list of keys previously associated with collections using setData() or attachData().

◆ getMessage()

const char* mvcresult::getMessage ( )

Returns the status message as set by a previous call to setStatus(), setSuccess(), setFailed(), or setMessage().

◆ getSuccess()

bool mvcresult::getSuccess ( )

Returns the status as set by a previous call to setStatus(), setSuccess(), setFailed(), or setSuccess().

◆ getWastebasket()

wastebasket* mvcresult::getWastebasket ( )

Returns the wastebasket.

◆ setCode()

void mvcresult::setCode ( uint32_t  code)

Sets the status code to "code" but does not change the status or status message.

◆ setData()

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.

◆ setFailed() [1/3]

void mvcresult::setFailed ( )

Sets the status to false (failure), status code to 0, and status message to NULL.

◆ setFailed() [2/3]

void mvcresult::setFailed ( uint32_t  code)

Sets the status to false (failure), status code to "code", and status message to NULL.

◆ setFailed() [3/3]

void mvcresult::setFailed ( uint32_t  code,
const char *  message 
)

Sets the status to false (failure), status code to "code", and status message to "message".

◆ setMessage()

void mvcresult::setMessage ( const char *  message)

Sets the status message to "message" but does not change the status or status code.

◆ setStatus() [1/3]

void mvcresult::setStatus ( bool  success)

Sets the status to "success", status code to 0, and status message to NULL.

◆ setStatus() [2/3]

void mvcresult::setStatus ( bool  success,
uint32_t  code 
)

Sets the status to "success", status code to "code", and status message to NULL.

◆ setStatus() [3/3]

void mvcresult::setStatus ( bool  success,
uint32_t  code,
const char *  message 
)

Sets the status to "success", status code to "code", and status message to "message".

◆ setSuccess() [1/4]

void mvcresult::setSuccess ( )

Sets the status to true (success), status code to 0, and status message to NULL.

◆ setSuccess() [2/4]

void mvcresult::setSuccess ( bool  success)

Sets the status "success" but does not change the status code or status message.

◆ setSuccess() [3/4]

void mvcresult::setSuccess ( uint32_t  code)

Sets the status to true (success), status code to "code", and status message to NULL.

◆ setSuccess() [4/4]

void mvcresult::setSuccess ( uint32_t  code,
const char *  message 
)

Sets the status to true (success), status code to "code", and status message to "message".

◆ write() [1/2]

ssize_t mvcresult::write ( )

Writes a representation (currently JSON) of the contents of the instance to standard output.

◆ write() [2/2]

ssize_t mvcresult::write ( output out)

Writes a representation (currently JSON) of the contents of the instance to "out".

◆ writeJson() [1/4]

ssize_t mvcresult::writeJson ( )

Writes an indented JSON representation of the contents of the instance to standard output.

◆ writeJson() [2/4]

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.

◆ writeJson() [3/4]

ssize_t mvcresult::writeJson ( output out)

Writes an indented JSON representation of the contents of the instance to "out".

◆ writeJson() [4/4]

ssize_t mvcresult::writeJson ( output out,
bool  indent 
)

Writes a JSON representation of the contents of the instance to "out".

The representation is indented if "indent" is true and not indented if "indent" is false.