Design Pattern Examples
Overview of object-oriented design patterns
dynamicstring.c File Reference

Implementation of the supporting functions for the DynamicString structure to work with dynamic strings. More...

#include <stdlib.h>
#include <string.h>
#include "dynamicstring.h"
Include dependency graph for dynamicstring.c:

Go to the source code of this file.

Functions

void DynamicString_Initialize (DynamicString *string)
 Initialize a DynamicString object to an empty string.
 
void DynamicString_Clear (DynamicString *string)
 Clear a DynamicString object, releasing any allocated memory. Resets to an empty string.
 
bool DynamicString_Append (DynamicString *string, const char *s)
 Append the specified string to the DynamicString object.
 
bool DynamicString_Set (DynamicString *string, const char *s)
 Set the DynamicString object to the specified string, replacing whatever is in the DynamicString object.
 

Detailed Description

Implementation of the supporting functions for the DynamicString structure to work with dynamic strings.

Definition in file dynamicstring.c.

Function Documentation

◆ DynamicString_Append()

bool DynamicString_Append ( DynamicString string,
const char *  s 
)

Append the specified string to the DynamicString object.

Note: DynamicString_Initialize() must be called first.

Parameters
stringThe DynamicString object to append to.
sThe string to append.
Returns
Returns true of the string was appended to successfully; otherwise, returns false, indicating an out of memory condition (or a NULL argument).

Definition at line 39 of file dynamicstring.c.

References DynamicString::string.

Referenced by _ListToString(), _StringizeStringList(), Composite_Exercise_FormatEntry(), DynamicString_Set(), HandlerChain_ToString(), Interpreter_Interpret(), Message_ToString(), MessagePosition_ToString(), MessageWindow_ToString(), and WindowRectangle_ToString().

◆ DynamicString_Clear()

◆ DynamicString_Initialize()

void DynamicString_Initialize ( DynamicString string)

Initialize a DynamicString object to an empty string.

Note: This must be the first call made to initialize a DynamicString object.

Parameters
stringThe DynamicString object to initialize.

Definition at line 15 of file dynamicstring.c.

Referenced by Decorator_Exercise(), DynamicString_Clear(), Message_ToString(), Proxy_Exercise(), and Shop_PlaceOrder().

◆ DynamicString_Set()

bool DynamicString_Set ( DynamicString string,
const char *  s 
)

Set the DynamicString object to the specified string, replacing whatever is in the DynamicString object.

Note: DynamicString_Initialize() must be called first.

Parameters
stringThe DynamicString object to set.
sThe string to set to.
Returns
Returns true of the string was set successfully; otherwise, returns false, indicating an out of memory condition (or a NULL argument).

Definition at line 73 of file dynamicstring.c.

References DynamicString_Append(), and DynamicString_Clear().

Referenced by _Decorate(), _Real_DoWork(), Decorator_Exercise(), Proxy_Exercise(), and State_RemoveComments().