Artifact d0143637ff26be7453b64cd2de89443d0d83a1351014664c3ce4888556179705:
- File
src/OFString.h
— part of check-in
[61a6ac873a]
at
2009-02-14 17:08:21
on branch trunk
— Big diff, see details.
* Add OFComparable protocol.
* Add OFInvalidArgument exception - needs that sel_getName vs.
sel_get_name stuff again, therefore reintroduce it.
* Implement proper copy method for OFString and OFArray.
* Add isEqual: and compare: for OFString and OFArray. (user: js, size: 3549) [annotate] [blame] [check-ins using]
/* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import <stdarg.h> #import <stdio.h> #import "OFObject.h" #import "OFComparable.h" /** * A class for storing and modifying strings. */ @interface OFString: OFObject <OFComparable> { char *string; size_t length; BOOL is_utf8; } /** * \return A new autoreleased OFString */ + string; /** * Creates a new OFString from a C string. * * \param str A C string to initialize the OFString with * \return A new autoreleased OFString */ + stringWithCString: (const char*)str; /** * Creates a new OFString from a format C string. * See printf for the format syntax. * * \param fmt A C string used as format to initialize the OFString * \return A new autoreleased OFString */ + stringWithFormat: (const char*)fmt, ...; /** * Creates a new OFString from a format C string. * See printf for the format syntax. * * \param fmt A C string used as format to initialize the OFString * \param args The arguments used in the format string * \return A new autoreleased OFString */ + stringWithFormat: (const char*)fmt andArguments: (va_list)args; /** * Initializes an already allocated OFString. * * \return An initialized OFString */ - init; /** * Initializes an already allocated OFString from a C string. * * \param str A C string to initialize the OFString with * \return An initialized OFString */ - initWithCString: (const char*)str; /** * Initializes an already allocated OFString from a format C string. * See printf for the format syntax. * * \param fmt A C string used as format to initialize the OFString * \return An initialized OFString */ - initWithFormat: (const char*)fmt, ...; /** * Initializes an already allocated OFString from a format C string. * See printf for the format syntax. * * \param fmt A C string used as format to initialize the OFString * \param args The arguments used in the format string * \return An initialized OFString */ - initWithFormat: (const char*)fmt andArguments: (va_list)args; /** * \return The OFString as a wide C string */ - (const char*)cString; /** * \return The length of the OFString */ - (size_t)length; /** * Clones the OFString, creating a new one. * * \return A new autoreleased copy of the OFString */ - (id)copy; /** * Sets the OFString to the specified OFString. * * \param str An OFString to set the OFString to. */ - setTo: (OFString*)str; /** * Append another OFString to the OFString. * * \param str An OFString to append */ - append: (OFString*)str; /** * Append a C string to the OFString. * * \param str A C string to append */ - appendCString: (const char*)str; /** * Append a formatted C string to the OFString. * See printf for the format syntax. * * \param fmt A format C string which generates the string to append */ - appendWithFormatCString: (const char*)fmt, ...; /** * Append a formatted C string to the OFString. * See printf for the format syntax. * * \param fmt A format C string which generates the string to append * \param args The arguments used in the format string */ - appendWithFormatCString: (const char*)fmt andArguments: (va_list)args; /** * Reverse the OFString. */ - reverse; /** * Upper the OFString. */ - upper; /** * Lower the OFString. */ - lower; @end