@@ -13,80 +13,107 @@ #import #import "OFObject.h" /** - * The OFString class can store and modify string of different types. - */ -@interface OFString: OFObject {} -/** - * \param str A constant C string from which the new OFConstCString will be - * created - * \return A new OFConstCString - */ -+ newAsConstCString: (const char*)str; - -/** - * \param str A constant wide C string from which the new OFConstCString will be - * created - * \return A new OFConstWideCString - */ -+ newAsConstWideCString: (const wchar_t*)str; - -/** - * \param str A C string from which the new OFConstCString will be created - * \return A new OFCString - */ -+ newAsCString: (char*)str; - -/** - * \param str A wide C string from which the new OFConstCString will be created - * \return A new OFWideCString - */ -+ newAsWideCString: (wchar_t*)str; - -/** - * \return The OFString as a C-type string of the type it was created as + * A class for storing and modifying strings. + */ +@interface OFString: OFObject +{ + wchar_t *string; + size_t length; +} + +/** + * Creates a new OFString. + * + * \return An initialized OFString + */ ++ new; + +/** + * Creates a new OFString from a C string. + * + * \param str A C string to initialize the OFString with + * \return A new OFString + */ ++ newFromCString: (const char*)str; + +/** + * Creates a new OFString from a wide C string. + * + * \param str A wide C string to initialize the OFString with + * \return A new OFString + */ ++ newFromWideCString: (const wchar_t*)str; + +/** + * 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 + */ +- initFromCString: (const char*)str; + +/** + * Initializes an already allocated OFString from a wide C string. + * + * \param str A wide C string to initialize the OFString with + * \return An initialized OFString + */ +- initFromWideCString: (const wchar_t*)str; + +/** + * \return The OFString as a C string, if possible (if not, returns NULL). + * If not needed anymore, it is usefull to call freeMem:. */ - (char*)cString; /** - * \return The OFString as a C-type wide string of the type it was created as + * \return The OFString as a wide C string */ -- (wchar_t*)wCString; +- (wchar_t*)wideCString; /** * \return The length of the OFString */ - (size_t)length; -/** - * Sets the OFString to the specified OFString. - * - * \param str The OFString to set the current OFString to - */ -- (OFString*)setTo: (OFString*)str; - /** * Clones the OFString, creating a new one. * * \return A copy of the OFString */ - (OFString*)clone; +/** + * Frees the OFString and sets it to the specified OFString. + * + * \param str An OFString to set the OFString to. + * \return The new OFString + */ +- (OFString*)setTo: (OFString*)str; + /** * Compares the OFString to another OFString. * - * \param str An OFString in a compatible type to compare with - * \return An integer which is the result of the comparison, see strcmp + * \param str An OFString to compare with + * \return An integer which is the result of the comparison, see wcscmp */ -- (int)compareTo: (OFString*)str; +- (int)compare: (OFString*)str; /** * Append another OFString to the OFString. * - * \param str An OFString in a compatible type to append + * \param str An OFString to append */ - append: (OFString*)str; /** * Append a C string to the OFString.