@@ -11,13 +11,10 @@ * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ -#ifndef OBJFW_OF_STRING_H -#define OBJFW_OF_STRING_H - #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS @@ -33,26 +30,23 @@ #include #ifdef OF_HAVE_INTTYPES_H # include #endif -#include "OFObject.h" -#ifdef __OBJC__ -# import "OFJSONRepresentation.h" -# import "OFMessagePackRepresentation.h" -#endif +#import "OFObject.h" +#import "OFJSONRepresentation.h" +#import "OFMessagePackRepresentation.h" OF_ASSUME_NONNULL_BEGIN /** @file */ -#ifdef __OBJC__ +@class OFArray OF_GENERIC(ObjectType); +@class OFCharacterSet; @class OFConstantString; +@class OFIRI; @class OFString; -#else -typedef void OFString; -#endif #if defined(__cplusplus) && __cplusplus >= 201103L typedef char16_t OFChar16; typedef char32_t OFChar32; #else @@ -130,15 +124,10 @@ * enumeration */ typedef void (^OFStringLineEnumerationBlock)(OFString *line, bool *stop); #endif -#ifdef __OBJC__ -@class OFArray OF_GENERIC(ObjectType); -@class OFCharacterSet; -@class OFIRI; - /** * @class OFString OFString.h ObjFW/OFString.h * * @brief A class for handling strings. */ @@ -275,11 +264,11 @@ /** * @brief The string with leading and trailing whitespaces deleted. */ @property (readonly, nonatomic) OFString *stringByDeletingEnclosingWhitespaces; -# ifdef OF_HAVE_UNICODE_TABLES +#ifdef OF_HAVE_UNICODE_TABLES /** * @brief The string in Unicode Normalization Form D (NFD). */ @property (readonly, nonatomic) OFString *decomposedStringWithCanonicalMapping; @@ -286,19 +275,19 @@ /** * @brief The string in Unicode Normalization Form KD (NFKD). */ @property (readonly, nonatomic) OFString *decomposedStringWithCompatibilityMapping; -# endif +#endif -# ifdef OF_WINDOWS +#ifdef OF_WINDOWS /** * @brief The string with the Windows Environment Strings expanded. */ @property (readonly, nonatomic) OFString *stringByExpandingWindowsEnvironmentStrings; -# endif +#endif /** * @brief Creates a new OFString. * * @return A new, autoreleased OFString @@ -524,11 +513,11 @@ * @throw OFInvalidEncodingException The resulting string is not in not in UTF-8 * encoding */ + (instancetype)stringWithFormat: (OFConstantString *)format, ...; -# ifdef OF_HAVE_FILES +#ifdef OF_HAVE_FILES /** * @brief Creates a new OFString with the contents of the specified UTF-8 * encoded file. * * @param path The path to the file @@ -546,11 +535,11 @@ * @return A new autoreleased OFString * @throw OFInvalidEncodingException The string is not in the specified encoding */ + (instancetype)stringWithContentsOfFile: (OFString *)path encoding: (OFStringEncoding)encoding; -# endif +#endif /** * @brief Creates a new OFString with the contents of the specified IRI. * * If the IRI's scheme is file, it tries UTF-8 encoding. @@ -817,11 +806,11 @@ * encoding */ - (instancetype)initWithFormat: (OFConstantString *)format arguments: (va_list)arguments; -# ifdef OF_HAVE_FILES +#ifdef OF_HAVE_FILES /** * @brief Initializes an already allocated OFString with the contents of the * specified file in the specified encoding. * * @param path The path to the file @@ -839,11 +828,11 @@ * @return An initialized OFString * @throw OFInvalidEncodingException The string is not in the specified encoding */ - (instancetype)initWithContentsOfFile: (OFString *)path encoding: (OFStringEncoding)encoding; -# endif +#endif /** * @brief Initializes an already allocated OFString with the contents of the * specified IRI. * @@ -1276,11 +1265,11 @@ * @throw OFInvalidEncodingException The string cannot be represented in the * specified encoding */ - (OFData *)dataWithEncoding: (OFStringEncoding)encoding; -# ifdef OF_HAVE_FILES +#ifdef OF_HAVE_FILES /** * @brief Writes the string into the specified file using UTF-8 encoding. * * @param path The path of the file to write to */ @@ -1294,11 +1283,11 @@ * @param encoding The encoding to use to write the string into the file * @throw OFInvalidEncodingException The string cannot be represented in the * specified encoding */ - (void)writeToFile: (OFString *)path encoding: (OFStringEncoding)encoding; -# endif +#endif /** * @brief Writes the string to the specified IRI using UTF-8 encoding. * * @param IRI The IRI to write to @@ -1313,20 +1302,19 @@ * @throw OFInvalidEncodingException The string cannot be represented in the * specified encoding */ - (void)writeToIRI: (OFIRI *)IRI encoding: (OFStringEncoding)encoding; -# ifdef OF_HAVE_BLOCKS +#ifdef OF_HAVE_BLOCKS /** * Enumerates all lines in the receiver using the specified block. * * @brief block The block to call for each line */ - (void)enumerateLinesUsingBlock: (OFStringLineEnumerationBlock)block; -# endif -@end #endif +@end #ifdef __cplusplus extern "C" { #endif /** @@ -1358,25 +1346,23 @@ } #endif OF_ASSUME_NONNULL_END -#include "OFConstantString.h" -#include "OFMutableString.h" -#ifdef __OBJC__ -# import "OFString+CryptographicHashing.h" -# import "OFString+JSONParsing.h" -# ifdef OF_HAVE_FILES -# import "OFString+PathAdditions.h" -# endif -# import "OFString+PercentEncoding.h" -# import "OFString+PropertyListParsing.h" -# import "OFString+XMLEscaping.h" -# import "OFString+XMLUnescaping.h" -#endif - -#if defined(__OBJC__) && !defined(NSINTEGER_DEFINED) && !__has_feature(modules) +#import "OFConstantString.h" +#import "OFMutableString.h" +#import "OFString+CryptographicHashing.h" +#import "OFString+JSONParsing.h" +#ifdef OF_HAVE_FILES +# import "OFString+PathAdditions.h" +#endif +#import "OFString+PercentEncoding.h" +#import "OFString+PropertyListParsing.h" +#import "OFString+XMLEscaping.h" +#import "OFString+XMLUnescaping.h" + +#if !defined(NSINTEGER_DEFINED) && !__has_feature(modules) /* * Very *ugly* hack required for string boxing literals to work. * * This hack is needed in order to work with `@class NSString` from Apple's * objc/NSString.h - which is included when using modules - as @@ -1387,8 +1373,6 @@ * * TODO: Submit a patch for Clang that makes the boxing classes configurable! */ @interface NSString: OFString @end -#endif - #endif