ADC Home > Reference Library > Reference > Darwin > Kernel Framework Reference

 


OSString

Inherits from:
Declared In:

Overview

A container class for managing strings.

Discussion

OSString is a container class for managing arrays of characters. Strings come in two varieties, mutable and immutable. An immutable OSString string is one which was created or initialized with the "NoCopy" functions; all other strings are mutable. When modifying an immutable string, the function called to perform the action will fail.



Functions

free

Releases all resources used by the OSString object.

getChar

Returns a character at the specified index in the string object.

getCStringNoCopy

Returns a pointer to the internal C string array.

getLength

Returns the length of the string.

initWithCString

Initializes an instance of OSString with a simple C string.

initWithCStringNoCopy

Initializes an instance of OSString with a simple C string, but does not copy the string into the container.

initWithString

Initializes an instance of OSString from another OSString object.

isEqualTo(const char *)

Tests the equality of the specified C string and the internal string array of the receiving OSString object.

isEqualTo(const OSData *)

Tests the equality of an unknown OSData object and the OSString instance.

isEqualTo(const OSMetaClassBase *)

Tests the equality of an unknown OSObject-derived object and the OSString instance.

isEqualTo(const OSString *)

Tests the equality of two OSString objects.

serialize

Archives the receiver.

setChar

Replaces a character at the specified index in the string object.

withCString

Creates and initializes an instance of OSString.

withCStringNoCopy

Creates and initializes an instance of OSString but does not copy the original C string into container.

withString

Creates and initializes an instance of OSString from another OSString.


free


Releases all resources used by the OSString object.

public

virtual void free();
Discussion

This function should not be called directly, use release() instead.


getChar


Returns a character at the specified index in the string object.

public

virtual char getChar( unsigned int index) const;
Parameters
index

The index into the string.

Return Value

Returns a character.


getCStringNoCopy


Returns a pointer to the internal C string array.

public

virtual const char *getCStringNoCopy() const;
Return Value

Returns a pointer to the internal C string array.


getLength


Returns the length of the string.

public

virtual unsigned int getLength() const;
Return Value

Returns the length of the string.


initWithCString


Initializes an instance of OSString with a simple C string.

public

virtual bool initWithCString( const char *cString);
Parameters
cString

A simple C string.

Return Value

Returns true on success, false otherwise.


initWithCStringNoCopy


Initializes an instance of OSString with a simple C string, but does not copy the string into the container.

public

virtual bool initWithCStringNoCopy( const char *cString);
Parameters
cString

A simple C string.

Return Value

Returns true on success, false otherwise.


initWithString


Initializes an instance of OSString from another OSString object.

public

virtual bool initWithString( const OSString *aString);
Parameters
aString

An OSString object.

Return Value

Returns true on success, false otherwise.


isEqualTo(const char *)


Tests the equality of the specified C string and the internal string array of the receiving OSString object.

public

virtual bool isEqualTo( const char *aCString) const;
Parameters
aCString

A simple C string.

Return Value

Returns true if the two strings are equal, false otherwise.


isEqualTo(const OSData *)


Tests the equality of an unknown OSData object and the OSString instance.

public

virtual bool isEqualTo( const OSData *obj) const;
Parameters
obj

An OSData object.

Return Value

Returns true if the two objects are equivalent, false otherwise.


isEqualTo(const OSMetaClassBase *)


Tests the equality of an unknown OSObject-derived object and the OSString instance.

public

virtual bool isEqualTo( const OSMetaClassBase *obj) const;
Parameters
obj

An OSObject-derived object.

Return Value

Returns true if the two objects are equivalent, false otherwise.


isEqualTo(const OSString *)


Tests the equality of two OSString objects.

public

virtual bool isEqualTo( const OSString *aString) const;
Parameters
aString

An OSString object.

Return Value

Returns true if the two strings are equal, false otherwise.


serialize


Archives the receiver.

public

virtual bool serialize( OSSerialize *s) const;
Parameters
s

The OSSerialize object.

Return Value

Returns true if serialization was successful, false if not.


setChar


Replaces a character at the specified index in the string object.

public

virtual bool setChar( char aChar, unsigned int index);
Parameters
index

The index into the string.

Return Value

Returns true if the character was successfully replaced or false if the string is immutable or index was beyond the bounds of the character array.


withCString


Creates and initializes an instance of OSString.

public

static OSString *withCString( const char *cString);
Parameters
cString

A simple C string.

Return Value

Returns an instance of OSString or 0 on error.


withCStringNoCopy


Creates and initializes an instance of OSString but does not copy the original C string into container.

public

static OSString *withCStringNoCopy( const char *cString);
Parameters
cString

A simple C string.

Return Value

Returns an instance of OSString or 0 on error.


withString


Creates and initializes an instance of OSString from another OSString.

public

static OSString *withString( const OSString *aString);
Parameters
aString

An OSString object.

Return Value

Returns an instance of OSString or 0 on error.


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.

 

Last Updated: 2008-12-19