Objectively 1.0.0
Ultra-lightweight object oriented framework for GNU C.
|
#include <String.h>
Immutable UTF-8 strings.
char
s. Be mindful of this when executing Range operations. setlocale
to enable localization. Properties | |
char * | chars |
The backing null-terminated UTF-8 encoded character array. More... | |
size_t | length |
The length of the String in bytes. More... | |
Object | object |
The superclass. More... | |
![]() | |
Class * | clazz |
Every instance of Object begins with a pointer to its Class. More... | |
Methods | |
Class * | _String (void) |
The String archetype. More... | |
Order | compareTo (const String *self, const String *other, const Range range) |
Compares this String lexicographically to another. More... | |
Array * | componentsSeparatedByCharacters (const String *self, const char *chars) |
Returns the components of this String that were separated by chars . More... | |
Array * | componentsSeparatedByString (const String *self, const String *string) |
Returns the components of this String that were separated by string . More... | |
Data * | getData (const String *self, StringEncoding encoding) |
Returns a Data with this String's contents in the given encoding. More... | |
_Bool | hasPrefix (const String *self, const String *prefix) |
Checks this String for the given prefix. More... | |
_Bool | hasSuffix (const String *self, const String *suffix) |
Checks this String for the given suffix. More... | |
String * | initWithBytes (String *self, const uint8_t *bytes, size_t length, StringEncoding encoding) |
Initializes this String by decoding length of bytes . More... | |
String * | initWithCharacters (String *self, const char *chars) |
Initializes this String by copying chars . More... | |
String * | initWithContentsOfFile (String *self, const char *path, StringEncoding encoding) |
Initializes this String with the contents of the FILE at path . More... | |
String * | initWithData (String *self, const Data *data, StringEncoding encoding) |
Initializes this String with the given Data. More... | |
String * | initWithFormat (String *self, const char *fmt,...) |
Initializes this String with the specified format string. More... | |
String * | initWithMemory (String *self, const ident mem, size_t length) |
Initializes this String with the specified buffer. More... | |
String * | initWithVaList (String *self, const char *fmt, va_list args) |
Initializes this String with the specified arguments list. More... | |
String * | lowercaseString (const String *self) |
MutableString * | mutableCopy (const String *self) |
Range | rangeOfCharacters (const String *self, const char *chars, const Range range) |
Finds and returns the first occurrence of chars in this String. More... | |
Range | rangeOfString (const String *self, const String *string, const Range range) |
Finds and returns the first occurrence of string in this String. More... | |
String * | stringWithBytes (const uint8_t *bytes, size_t length, StringEncoding encoding) |
Returns a new String by decoding length of bytes to UTF-8. More... | |
String * | stringWithCharacters (const char *chars) |
Returns a new String by copying chars . More... | |
String * | stringWithContentsOfFile (const char *path, StringEncoding encoding) |
Returns a new String with the contents of the FILE at path . More... | |
String * | stringWithData (const Data *data, StringEncoding encoding) |
Returns a new String with the the given Data. More... | |
String * | stringWithFormat (const char *fmt) |
Returns a new String with the given format string. More... | |
String * | stringWithMemory (const ident mem, size_t length) |
Returns a new String with the given buffer. More... | |
String * | substring (const String *string, const Range range) |
Creates a new String from a subset of this one. More... | |
String * | trimmedString (const String *self) |
Creates a copy of this String with leading and trailing whitespace removed. More... | |
String * | uppercaseString (const String *self) |
_Bool | writeToFile (const String *self, const char *path, StringEncoding encoding) |
Writes this String to path . More... | |
![]() | |
Class * | _Object (void) |
The Object archetype. More... | |
Object * | copy (const Object *self) |
Creates a shallow copy of this Object. More... | |
void | dealloc (Object *self) |
Frees all resources held by this Object. More... | |
String * | description (const Object *self) |
int | hash (const Object *self) |
Object * | init (Object *self) |
Initializes this Object. More... | |
_Bool | isEqual (const Object *self, const Object *other) |
Tests equality of the other Object. More... | |
_Bool | isKindOfClass (const Object *self, const Class *clazz) |
Tests for Class hierarchy membership. More... | |
Protected Attributes | |
StringInterface * | interface |
The interface. More... | |
![]() | |
ObjectInterface * | interface |
The interface. More... | |
Related Functions | |
OBJECTIVELY_EXPORT MutableString * | mstr (const char *fmt,...) |
A convenience function for instantiating MutableStrings. More... | |
OBJECTIVELY_EXPORT const char * | NameForStringEncoding (StringEncoding encoding) |
OBJECTIVELY_EXPORT String * | str (const char *fmt,...) |
A convenience function for instantiating Strings. More... | |
OBJECTIVELY_EXPORT Order | StringCompare (const ident a, const ident b) |
A Comparator for sorting Strings. More... | |
OBJECTIVELY_EXPORT StringEncoding | StringEncodingForName (const char *name) |
char* String::chars |
Class * _String | ( | void | ) |
The String archetype.
Definition at line 654 of file String.c.
Compares this String lexicographically to another.
other
. Definition at line 163 of file String.c.
Returns the components of this String that were separated by chars
.
self | The String. |
chars | The separating characters. |
chars
. Definition at line 184 of file String.c.
Returns the components of this String that were separated by string
.
string
. Definition at line 217 of file String.c.
Data * getData | ( | const String * | self, |
StringEncoding | encoding | ||
) |
Returns a Data with this String's contents in the given encoding.
self | The String. |
encoding | The desired StringEncoding. |
Definition at line 228 of file String.c.
Checks this String for the given prefix.
self | The String. |
prefix | The Prefix to check. |
Definition at line 251 of file String.c.
String * initWithBytes | ( | String * | self, |
const uint8_t * | bytes, | ||
size_t | length, | ||
StringEncoding | encoding | ||
) |
Initializes this String by decoding length
of bytes
.
self | The String. |
bytes | The bytes. |
length | The length of bytes to decode. |
encoding | The character encoding. |
NULL
on error. Definition at line 279 of file String.c.
String * initWithContentsOfFile | ( | String * | self, |
const char * | path, | ||
StringEncoding | encoding | ||
) |
Initializes this String with the contents of the FILE at path
.
self | The String. |
path | The path of the file to load. |
encoding | The character encoding. |
NULL
on error. Definition at line 328 of file String.c.
String * initWithData | ( | String * | self, |
const Data * | data, | ||
StringEncoding | encoding | ||
) |
Initializes this String with the given Data.
NULL
on error. Definition at line 345 of file String.c.
Initializes this String with the specified format string.
self | The String. |
fmt | The format string. |
NULL
on error. Definition at line 356 of file String.c.
Initializes this String with the specified buffer.
self | The String. |
mem | The dynamically allocated null-terminated, UTF-8 encoded buffer. |
length | The length of mem in printable characters. |
NULL
on error. Definition at line 372 of file String.c.
self | The String. |
Definition at line 410 of file String.c.
MutableString * mutableCopy | ( | const String * | self | ) |
self | The String. |
Definition at line 432 of file String.c.
Finds and returns the first occurrence of chars
in this String.
Definition at line 441 of file String.c.
Finds and returns the first occurrence of string
in this String.
String * stringWithBytes | ( | const uint8_t * | bytes, |
size_t | length, | ||
StringEncoding | encoding | ||
) |
String * stringWithCharacters | ( | const char * | chars | ) |
Returns a new String by copying chars
.
chars | The null-terminated UTF-8 encoded C string. |
NULL
on error. Definition at line 487 of file String.c.
String * stringWithContentsOfFile | ( | const char * | path, |
StringEncoding | encoding | ||
) |
Returns a new String with the contents of the FILE at path
.
path | A path name. |
encoding | The character encoding. |
NULL
on error. Definition at line 496 of file String.c.
String * stringWithData | ( | const Data * | data, |
StringEncoding | encoding | ||
) |
String * stringWithFormat | ( | const char * | fmt | ) |
_Bool writeToFile | ( | const String * | self, |
const char * | path, | ||
StringEncoding | encoding | ||
) |
Writes this String to path
.
self | The String. |
path | The path of the file to write. |
encoding | The character encoding. |
true
on success, false
on error. Definition at line 597 of file String.c.
|
related |
A convenience function for instantiating MutableStrings.
fmt | The format string. |
NULL
on error. Definition at line 379 of file MutableString.c.
|
related |
encoding | A StringEncoding. |
Definition at line 674 of file String.c.
|
related |
|
related |
|
related |
name | The case-insensitive name of the encoding. |
name
. Definition at line 698 of file String.c.