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

Declaration of the DynamicString structure and supporting functions to work with dynamic strings. More...

#include <stdbool.h>
Include dependency graph for dynamicstring.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  DynamicString
 Represents a string that can be grown dynamically. More...
 

Macros

#define __DYNAMICSTRING_H__
 

Typedefs

typedef struct DynamicString DynamicString
 Represents a string that can be grown dynamically.
 

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

Declaration of the DynamicString structure and supporting functions to work with dynamic strings.

Definition in file dynamicstring.h.

Macro Definition Documentation

◆ __DYNAMICSTRING_H__

#define __DYNAMICSTRING_H__

Definition at line 8 of file dynamicstring.h.

Typedef Documentation

◆ DynamicString

typedef struct DynamicString DynamicString

Represents a string that can be grown dynamically.

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().