Objectively 1.0.0
Ultra-lightweight object oriented framework for GNU C.
MutableString.h
Go to the documentation of this file.
1/*
2 * Objectively: Ultra-lightweight object oriented framework for GNU C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
26#include <Objectively/String.h>
27
33typedef struct MutableStringInterface MutableStringInterface;
34
41
46
51 MutableStringInterface *interface;
52
58 size_t capacity;
59};
60
64struct MutableStringInterface {
65
69 StringInterface stringInterface;
70
78 void (*appendCharacters)(MutableString *self, const char *chars);
79
87 void (*appendFormat)(MutableString *self, const char *fmt, ...);
88
96 void (*appendString)(MutableString *self, const String *string);
97
106 void (*appendVaList)(MutableString *self, const char *fmt, va_list args);
107
115 void (*deleteCharactersInRange)(MutableString *self, const Range range);
116
124 MutableString *(*init)(MutableString *self);
125
134 MutableString *(*initWithCapacity)(MutableString *self, size_t capacity);
135
144 MutableString *(*initWithString)(MutableString *self, const String *string);
145
154 void (*insertCharactersAtIndex)(MutableString *self, const char *chars, size_t index);
155
164 void (*insertStringAtIndex)(MutableString *self, const String *string, size_t index);
165
174 void (*replaceCharactersInRange)(MutableString *self, const Range range, const char *chars);
175
184 void (*replaceOccurrencesOfCharacters)(MutableString *self, const char *chars, const char *replacement);
185
195 void (*replaceOccurrencesOfCharactersInRange)(MutableString *self, const char *chars, const Range range, const char *replacement);
196
205 void (*replaceOccurrencesOfString)(MutableString *self, const String *string, const String *replacement);
206
216 void (*replaceOccurrencesOfStringInRange)(MutableString *self, const String *string, const Range range, const String *replacement);
217
226 void (*replaceStringInRange)(MutableString *self, const Range range, const String *string);
227
235 MutableString *(*string)(void);
236
245 MutableString *(*stringWithCapacity)(size_t capacity);
246
253 void (*trim)(MutableString *self);
254};
255
263
270OBJECTIVELY_EXPORT MutableString *mstr(const char *fmt, ...);
static MutableString * string(void)
static void replaceOccurrencesOfStringInRange(MutableString *self, const String *string, const Range range, const String *replacement)
static void appendFormat(MutableString *self, const char *fmt,...)
Definition: MutableString.c:89
static void replaceStringInRange(MutableString *self, const Range range, const String *string)
static void deleteCharactersInRange(MutableString *self, const Range range)
static void replaceCharactersInRange(MutableString *self, const Range range, const char *chars)
static void replaceOccurrencesOfCharactersInRange(MutableString *self, const char *chars, const Range range, const char *replacement)
static void appendVaList(MutableString *self, const char *fmt, va_list args)
static void trim(MutableString *self)
static void replaceOccurrencesOfCharacters(MutableString *self, const char *chars, const char *replacement)
static void insertCharactersAtIndex(MutableString *self, const char *chars, size_t index)
static void replaceOccurrencesOfString(MutableString *self, const String *string, const String *replacement)
static void insertStringAtIndex(MutableString *self, const String *string, size_t index)
static void appendString(MutableString *self, const String *string)
static void appendCharacters(MutableString *self, const char *chars)
Definition: MutableString.c:54
Immutable UTF-8 strings.
#define OBJECTIVELY_EXPORT
Definition: Types.h:36
The runtime representation of a Class.
Definition: Class.h:95
Mutable UTF-8 strings.
Definition: MutableString.h:40
String string
The superclass.
Definition: MutableString.h:45
Class * _MutableString(void)
The MutableString archetype.
MutableStringInterface * interface
The interface.
Definition: MutableString.h:51
A location and length into contiguous collections.
Definition: Types.h:54
Immutable UTF-8 strings.
Definition: String.h:69
OBJECTIVELY_EXPORT MutableString * mstr(const char *fmt,...)
A convenience function for instantiating MutableStrings.