Declaration of the Memento_TextObject structure and support functions, Memento_TextObject_Create(), Memento_TextObject_Destroy(), Memento_TextObject_GetText(), Memento_TextObject_SetText(), and Memento_TextObject_ToString(), as used in the Memento Pattern. More...
Go to the source code of this file.
Classes | |
struct | Memento_TextObject |
Container for a string. More... | |
Macros | |
#define | __MEMENTO_TEXTOBJECT_H__ |
Functions | |
Memento_TextObject * | Memento_TextObject_Create (const char *text) |
Create a new instance of the Memento_TextObject structure and initialize it with the given text. | |
void | Memento_TextObject_Destroy (Memento_TextObject *textObject) |
Destroy the given Memento_TextObject object and release any used memory. After this function returns, the pointer is no longer valid. | |
char * | Memento_TextObject_GetText (Memento_TextObject *textObject) |
Retrieve a pointer to the text contained within the Memento_TextObject. The text can be altered through this pointer or can be replaced entirely using the Memento_TextObject_SetText() function. | |
void | Memento_TextObject_SetText (Memento_TextObject *textObject, const char *newText) |
Replace the existing text in the Memento_TextObject object with the given text. | |
const char * | Memento_TextObject_ToString (Memento_TextObject *textObject) |
Return a string representation of the Memento_TextObject. In this case, it is just the underlying text. | |
Declaration of the Memento_TextObject structure and support functions, Memento_TextObject_Create(), Memento_TextObject_Destroy(), Memento_TextObject_GetText(), Memento_TextObject_SetText(), and Memento_TextObject_ToString(), as used in the Memento Pattern.
Definition in file Memento_TextObject.h.
#define __MEMENTO_TEXTOBJECT_H__ |
Definition at line 11 of file Memento_TextObject.h.
Memento_TextObject * Memento_TextObject_Create | ( | const char * | text | ) |
Create a new instance of the Memento_TextObject structure and initialize it with the given text.
text | The text with which to initialize the Memento_TextObject. This is duplicated. |
Definition at line 21 of file Memento_TextObject.c.
References STRDUP, and Memento_TextObject::text.
Referenced by Memento_Exercise().
void Memento_TextObject_Destroy | ( | Memento_TextObject * | textObject | ) |
Destroy the given Memento_TextObject object and release any used memory. After this function returns, the pointer is no longer valid.
textObject | The Memento_TextObject to destroy. |
Definition at line 50 of file Memento_TextObject.c.
References Memento_TextObject::text.
Referenced by Memento_Exercise().
char * Memento_TextObject_GetText | ( | Memento_TextObject * | textObject | ) |
Retrieve a pointer to the text contained within the Memento_TextObject. The text can be altered through this pointer or can be replaced entirely using the Memento_TextObject_SetText() function.
textObject | The Memento_TextObject object from which to get the text. |
Definition at line 62 of file Memento_TextObject.c.
References Memento_TextObject::text.
Referenced by Memento_Operation_Replace(), Memento_Operation_Reverse(), and Memento_SaveForUndo().
void Memento_TextObject_SetText | ( | Memento_TextObject * | textObject, |
const char * | newText | ||
) |
Replace the existing text in the Memento_TextObject object with the given text.
textObject | The Memento_TextObject from which to get the text. |
newText | The new text to set the Memento_TextObject to. This string is duplicated. |
Definition at line 77 of file Memento_TextObject.c.
References STRDUP, and Memento_TextObject::text.
Referenced by Memento_Operation_Replace(), and Memento_Undo().
const char * Memento_TextObject_ToString | ( | Memento_TextObject * | textObject | ) |
Return a string representation of the Memento_TextObject. In this case, it is just the underlying text.
textObject | The Memento_TextObject from which to create a string. |
Definition at line 94 of file Memento_TextObject.c.
References Memento_TextObject::text.
Referenced by Memento_ApplyReplaceOperation(), Memento_ApplyReverseOperation(), Memento_Exercise(), and Memento_Undo().