Implementation of the Command_TextObject structure and associated functions as used in the Command Pattern. More...
#include <memory.h>
#include <stdlib.h>
#include <string.h>
#include "helpers/strdup.h"
#include "Command_TextObject.h"
Go to the source code of this file.
Functions | |
bool | Command_TextObject_Initialize (Command_TextObject *textObject, const char *startingText) |
Initialize a Command_TextObject with the specified text. | |
void | Command_TextObject_Clear (Command_TextObject *textObject) |
Clear the contents of the specified Command_TextObject, releasing any allocated resources associated with the Command_TextObject. | |
void | Command_TextObject_Reset (Command_TextObject *textObject) |
Resets the Command_TextObject to the starting string. | |
char * | Command_TextObject_GetText (Command_TextObject *textObject) |
Gets the text in the specified Command_TextObject. | |
void | Command_TextObject_SetText (Command_TextObject *textObject, const char *newText) |
Sets the text in the specified Command_TextObject. | |
const char * | Command_TextObject_ToString (Command_TextObject *textObject) |
Converts the Command_TextObject to a string (basically, returns the current text from the Command_TextObject). | |
Implementation of the Command_TextObject structure and associated functions as used in the Command Pattern.
Definition in file Command_TextObject.c.
void Command_TextObject_Clear | ( | Command_TextObject * | textObject | ) |
Clear the contents of the specified Command_TextObject, releasing any allocated resources associated with the Command_TextObject.
textObject | A Command_TextObject whose contents are to be destroyed. |
Definition at line 35 of file Command_TextObject.c.
References Command_TextObject::startingText, and Command_TextObject::text.
Referenced by Command_Exercise(), and Command_TextObject_Initialize().
char * Command_TextObject_GetText | ( | Command_TextObject * | textObject | ) |
Gets the text in the specified Command_TextObject.
textObject | The Command_TextObject from which to get the text. |
Definition at line 60 of file Command_TextObject.c.
References Command_TextObject::text.
Referenced by Command_Operation_Replace(), and Command_Operation_Reverse().
bool Command_TextObject_Initialize | ( | Command_TextObject * | textObject, |
const char * | startingText | ||
) |
Initialize a Command_TextObject with the specified text.
textObject | A Command_TextObject to initialize with the given text. |
startingText | The text with which to initialize the object. String is not duplicated. |
Definition at line 18 of file Command_TextObject.c.
References Command_TextObject_Clear(), Command_TextObject::startingText, STRDUP, and Command_TextObject::text.
Referenced by Command_Exercise().
void Command_TextObject_Reset | ( | Command_TextObject * | textObject | ) |
Resets the Command_TextObject to the starting string.
textObject | The Command_TextObject to reset. |
Definition at line 48 of file Command_TextObject.c.
References Command_TextObject::startingText, STRDUP, and Command_TextObject::text.
Referenced by Command_Undo().
void Command_TextObject_SetText | ( | Command_TextObject * | textObject, |
const char * | newText | ||
) |
Sets the text in the specified Command_TextObject.
textObject | The Command_TextObject in which to change the mutable text. |
newText | The text to change to. |
Definition at line 75 of file Command_TextObject.c.
References STRDUP, and Command_TextObject::text.
Referenced by Command_Operation_Replace().
const char * Command_TextObject_ToString | ( | Command_TextObject * | textObject | ) |
Converts the Command_TextObject to a string (basically, returns the current text from the Command_TextObject).
textObject | The Command_TextObject from which to get the current text. |
Definition at line 87 of file Command_TextObject.c.
References Command_TextObject::text.
Referenced by Command_ApplyReplaceCommand(), Command_ApplyReverseCommand(), Command_Exercise(), and Command_Undo().