|
Objectively
Ultra-lightweight object oriented framework for GNU C.
|
#include <String.h>
UTF-8 strings.
chars. Be mindful of this when executing Range operations. setlocale to enable localization.
Properties | |
| char * | chars |
| The backing null-terminated UTF-8 encoded character array. | |
| size_t | length |
| The length of the String in bytes. | |
| Object | object |
| The superclass. | |
Properties inherited from Object | |
| Class * | clazz |
| Every instance of Object begins with a pointer to its Class. | |
| unsigned int | magic |
| A header to allow introspection of Object types. | |
Methods | |
| Class * | _String (void) |
| The String archetype. | |
| void | appendBytes (String *self, const uint8_t *bytes, size_t length, StringEncoding encoding) |
Appends the decoded contents of bytes. | |
| void | appendCharacters (String *self, const char *chars) |
| Appends the specified UTF-8 encoded C string. | |
| void | appendFormat (String *self, const char *fmt,...) |
| Appends the specified formatted string. | |
| void | appendString (String *self, const String *string) |
| Appends the specified String to this String. | |
| void | appendVaList (String *self, const char *fmt, va_list args) |
| Appends the specified format string. | |
| Order | compareTo (const String *self, const String *other, const Range range) |
| Compares this String lexicographically to another. | |
| Array * | componentsSeparatedByCharacters (const String *self, const char *chars) |
Returns the components of this String that were separated by chars. | |
| Array * | componentsSeparatedByString (const String *self, const String *string) |
Returns the components of this String that were separated by string. | |
| void | deleteCharactersInRange (String *self, const Range range) |
Deletes the characters within range from this String. | |
| Data * | getData (const String *self, StringEncoding encoding) |
| Returns a Data with this String's contents in the given encoding. | |
| bool | hasPrefix (const String *self, const String *prefix) |
| Checks this String for the given prefix. | |
| bool | hasSuffix (const String *self, const String *suffix) |
| Checks this String for the given suffix. | |
| String * | init (String *self) |
| Initializes this String. | |
| String * | initWithBytes (String *self, const uint8_t *bytes, size_t length, StringEncoding encoding) |
Initializes this String by decoding length of bytes. | |
| String * | initWithCapacity (String *self, size_t capacity) |
Initializes this String with the given capacity. | |
| String * | initWithCharacters (String *self, const char *chars) |
Initializes this String by copying chars. | |
| String * | initWithContentsOfFile (String *self, const char *path, StringEncoding encoding) |
Initializes this String with the contents of the FILE at path. | |
| String * | initWithData (String *self, const Data *data, StringEncoding encoding) |
| Initializes this String with the given Data. | |
| String * | initWithFormat (String *self, const char *fmt,...) |
| Initializes this String with the specified format string. | |
| String * | initWithMemory (String *self, const ident mem, size_t length) |
| Initializes this String with the specified buffer. | |
| String * | initWithString (String *self, const String *string) |
Initializes this String with the contents of string. | |
| String * | initWithVaList (String *self, const char *fmt, va_list args) |
| Initializes this String with the specified arguments list. | |
| void | insertCharactersAtIndex (String *self, const char *chars, size_t index) |
| Inserts the specified String at the given index. | |
| void | insertStringAtIndex (String *self, const String *string, size_t index) |
| Inserts the specified String at the given index. | |
| String * | lowercaseString (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. | |
| Range | rangeOfString (const String *self, const String *string, const Range range) |
Finds and returns the first occurrence of string in this String. | |
| void | replaceCharactersInRange (String *self, const Range range, const char *chars) |
Replaces the characters in range with the given characters. | |
| void | replaceOccurrencesOfCharacters (String *self, const char *chars, const char *replacement) |
Replaces all occurrences of chars with the given replacement. | |
| void | replaceOccurrencesOfCharactersInRange (String *self, const char *chars, const Range range, const char *replacement) |
Replaces occurrences of chars in range with the given replacement. | |
| void | replaceOccurrencesOfString (String *self, const String *string, const String *replacement) |
Replaces all occurrences of string with the given replacement. | |
| void | replaceOccurrencesOfStringInRange (String *self, const String *string, const Range range, const String *replacement) |
Replaces occurrences of string in range with the given replacement. | |
| void | replaceStringInRange (String *self, const Range range, const String *string) |
Replaces the characters in range with the contents of string. | |
| void | setCharacters (String *self, const char *chars) |
Sets the contents of this String to chars. | |
| void | setFormat (String *self, const char *fmt) |
| Sets the contents of this String to the formatted string. | |
| void | setFormat (String *self, const char *fmt,...) |
| void | setLength (String *self, size_t length) |
Sets the length of this String to length. | |
| void | setString (String *self, const String *string) |
Sets the contents of this String to that of string. | |
| String * | string (void) |
| Returns a new String. | |
| String * | stringWithBytes (const uint8_t *bytes, size_t length, StringEncoding encoding) |
Returns a new String by decoding length of bytes to UTF-8. | |
| String * | stringWithCapacity (size_t capacity) |
Returns a new String with the given capacity. | |
| String * | stringWithCharacters (const char *chars) |
Returns a new String by copying chars. | |
| String * | stringWithContentsOfFile (const char *path, StringEncoding encoding) |
Returns a new String with the contents of the FILE at path. | |
| String * | stringWithData (const Data *data, StringEncoding encoding) |
| Returns a new String with the the given Data. | |
| String * | stringWithFormat (const char *fmt) |
| Returns a new String with the given format string. | |
| String * | stringWithMemory (const ident mem, size_t length) |
| Returns a new String with the given buffer. | |
| String * | substring (const String *string, const Range range) |
| Creates a new String from a subset of this one. | |
| void | trim (String *self) |
| Trims leading and trailing whitespace from this String. | |
| String * | trimmedString (const String *self) |
| Creates a copy of this String with leading and trailing whitespace removed. | |
| String * | uppercaseString (const String *self) |
| bool | writeToFile (const String *self, const char *path, StringEncoding encoding) |
Writes this String to path. | |
Methods inherited from Object | |
| Class * | _Object (void) |
| The Object archetype. | |
| Object * | copy (const Object *self) |
| Creates a shallow copy of this Object. | |
| void | dealloc (Object *self) |
| Frees all resources held by this Object. | |
| String * | description (const Object *self) |
| int | hash (const Object *self) |
| Object * | init (Object *self) |
| Initializes this Object. | |
| bool | isEqual (const Object *self, const Object *other) |
| Tests equality of the other Object. | |
| bool | isKindOfClass (const Object *self, const Class *clazz) |
| Tests for Class hierarchy membership. | |
Protected Attributes | |
| StringInterface * | interface |
| The interface. | |
Protected Attributes inherited from Object | |
| ObjectInterface * | interface |
| The interface. | |
Related Symbols | |
| OBJECTIVELY_EXPORT const char * | NameForStringEncoding (StringEncoding encoding) |
| OBJECTIVELY_EXPORT String * | str (const char *fmt,...) |
| A convenience function for instantiating Strings. | |
| OBJECTIVELY_EXPORT Order | StringCompare (const ident a, const ident b) |
| A Comparator for sorting Strings. | |
| OBJECTIVELY_EXPORT StringEncoding | StringEncodingForName (const char *name) |
| char* String::chars |
| Class * _String | ( | void | ) |
The String archetype.
Definition at line 999 of file String.c.
| void appendBytes | ( | String * | self, |
| const uint8_t * | bytes, | ||
| size_t | length, | ||
| StringEncoding | encoding | ||
| ) |
Appends the decoded contents of bytes.
| self | The String. |
| bytes | The bytes. |
| length | The length of bytes to decode. |
| encoding | The character encoding. |
Definition at line 476 of file String.c.
| void appendCharacters | ( | String * | self, |
| const char * | chars | ||
| ) |
Appends the specified UTF-8 encoded C string.
| self | The String. |
| chars | A UTF-encoded C string. |
Definition at line 506 of file String.c.
| void appendFormat | ( | String * | self, |
| const char * | fmt, | ||
| ... | |||
| ) |
Appends the specified formatted string.
| self | The String. |
| fmt | The format string. |
Definition at line 541 of file String.c.
| void appendVaList | ( | String * | self, |
| const char * | fmt, | ||
| va_list | args | ||
| ) |
Returns the components of this String that were separated by chars.
| self | The String. |
| chars | The separating characters. |
chars. Definition at line 182 of file String.c.
Returns the components of this String that were separated by string.
string. Definition at line 215 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. |
Checks this String for the given prefix.
| self | The String. |
| prefix | The Prefix to check. |
Definition at line 249 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 606 of file String.c.
Initializes this String with the given capacity.
| self | The String. |
| capacity | The capacity, in bytes. |
NULL on error. Definition at line 620 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 652 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 669 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 680 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 700 of file String.c.
Initializes this String with the contents of string.
NULL on error. Definition at line 716 of file String.c.
Initializes this String with the specified arguments list.
| self | The String. |
| fmt | The format string. |
| args | The format arguments. |
NULL on error.Definition at line 730 of file String.c.
| void insertCharactersAtIndex | ( | String * | self, |
| const char * | chars, | ||
| size_t | index | ||
| ) |
Inserts the specified String at the given index.
| self | The String. |
| chars | The null-terminated UTF-8 encoded C string to insert. |
| index | The index. |
Definition at line 744 of file String.c.
Inserts the specified String at the given index.
Definition at line 755 of file String.c.
| self | The String. |
Definition at line 281 of file String.c.
Finds and returns the first occurrence of chars in this String.
Definition at line 303 of file String.c.
Finds and returns the first occurrence of string in this String.
Replaces the characters in range with the given characters.
| self | The String. |
| range | The Range of characters to replace. |
| chars | The null-terminated UTF-8 encoded C string to substitute. |
Definition at line 764 of file String.c.
| void replaceOccurrencesOfCharacters | ( | String * | self, |
| const char * | chars, | ||
| const char * | replacement | ||
| ) |
Replaces all occurrences of chars with the given replacement.
| self | The String. |
| chars | The null-terminated UTF-8 encoded C string to replace. |
| replacement | The null-terminated UTF-8 encoded C string replacement. |
Definition at line 788 of file String.c.
| void replaceOccurrencesOfCharactersInRange | ( | String * | self, |
| const char * | chars, | ||
| const Range | range, | ||
| const char * | replacement | ||
| ) |
Replaces occurrences of chars in range with the given replacement.
| self | The String. |
| chars | The null-terminated UTF-8 encoded C string to replace. |
| range | The Range in which to replace. |
| replacement | The null-terminated UTF-8 encoded C string replacement. |
Definition at line 796 of file String.c.
| void replaceOccurrencesOfString | ( | String * | self, |
| const String * | string, | ||
| const String * | replacement | ||
| ) |
Replaces all occurrences of string with the given replacement.
Definition at line 826 of file String.c.
| void replaceOccurrencesOfStringInRange | ( | String * | self, |
| const String * | string, | ||
| const Range | range, | ||
| const String * | replacement | ||
| ) |
| void setCharacters | ( | String * | self, |
| const char * | chars | ||
| ) |
Sets the contents of this String to chars.
| self | The String. |
| chars | The characters to set, or NULL. |
Definition at line 855 of file String.c.
| void setFormat | ( | String * | self, |
| const char * | fmt | ||
| ) |
| void setFormat | ( | String * | self, |
| const char * | fmt, | ||
| ... | |||
| ) |
Definition at line 866 of file String.c.
| void setLength | ( | String * | self, |
| size_t | length | ||
| ) |
| String * string | ( | void | ) |
| String * stringWithBytes | ( | const uint8_t * | bytes, |
| size_t | length, | ||
| StringEncoding | encoding | ||
| ) |
| String * stringWithCapacity | ( | size_t | capacity | ) |
| 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 349 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 358 of file String.c.
| String * stringWithData | ( | const Data * | data, |
| StringEncoding | encoding | ||
| ) |
| String * stringWithFormat | ( | const char * | fmt | ) |
| void trim | ( | String * | self | ) |
Trims leading and trailing whitespace from this String.
| self | The String. |
Definition at line 921 of file String.c.
| 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 459 of file String.c.
|
related |
| encoding | A StringEncoding. |
Definition at line 1019 of file String.c.
|
related |
A convenience function for instantiating Strings.
| fmt | The format string. |
NULL on error. Definition at line 1084 of file String.c.
|
related |
|
related |
| name | The case-insensitive name of the encoding. |
name. Definition at line 1043 of file String.c.