From f3507e03682459d068c53f8f3bfe921bca531053 Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 18 Jul 2005 09:27:32 +0000 Subject: [PATCH] added -isNotEmpty git-svn-id: http://svn.opengroupware.org/SOPE/trunk@911 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-core/NGExtensions/ChangeLog | 6 +++++ .../NGExtensions/FdExt.subproj/NSNull+misc.m | 25 +++++++++++++++++++ .../NGExtensions/NGExtensions/NSNull+misc.h | 1 + sope-core/NGExtensions/Version | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/sope-core/NGExtensions/ChangeLog b/sope-core/NGExtensions/ChangeLog index 9576a1e6..10e9505a 100644 --- a/sope-core/NGExtensions/ChangeLog +++ b/sope-core/NGExtensions/ChangeLog @@ -1,3 +1,9 @@ +2005-07-18 Helge Hess + + * FdExt.subproj/NSNull+misc.m: added -isNotEmpty to all objects. Its + similiar to -isNotNull but also checks for strings composed of just + spaces (v4.5.162) + 2005-07-11 Helge Hess * NGResourceLocator.m: added -description, added method diff --git a/sope-core/NGExtensions/FdExt.subproj/NSNull+misc.m b/sope-core/NGExtensions/FdExt.subproj/NSNull+misc.m index 15846eb4..0b7867ba 100644 --- a/sope-core/NGExtensions/FdExt.subproj/NSNull+misc.m +++ b/sope-core/NGExtensions/FdExt.subproj/NSNull+misc.m @@ -47,6 +47,9 @@ static inline BOOL doAbort(void) { - (BOOL)isNotNull { return NO; } +- (BOOL)isNotEmpty { + return NO; +} - (BOOL)isNull { #if DEBUG NSLog(@"WARNING(%s): called deprecated -isNull on NSNull (use -isNotNull) !", @@ -205,11 +208,15 @@ static inline BOOL doAbort(void) { @end /* NSNull(misc) */ + @implementation NSObject(NSNullMisc) - (BOOL)isNotNull { return YES; } +- (BOOL)isNotEmpty { + return [self isNotNull]; +} - (BOOL)isNull { #if DEBUG @@ -221,3 +228,21 @@ static inline BOOL doAbort(void) { @end /* NSObject(NSNullMisc) */ + +@implementation NSString(NSNullMisc) + +- (BOOL)isNotEmpty { + unsigned i, len; + + if ((len = [self length]) == 0) + return NO; + + for (i = 0; i < len; i++) { + if (!isspace([self characterAtIndex:i])) + return YES; + } + + return NO; +} + +@end /* NSString(NSNullMisc) */ diff --git a/sope-core/NGExtensions/NGExtensions/NSNull+misc.h b/sope-core/NGExtensions/NGExtensions/NSNull+misc.h index 4df840f4..fba5d62d 100644 --- a/sope-core/NGExtensions/NGExtensions/NSNull+misc.h +++ b/sope-core/NGExtensions/NGExtensions/NSNull+misc.h @@ -36,6 +36,7 @@ @interface NSObject(NSNullMisc) - (BOOL)isNotNull; +- (BOOL)isNotEmpty; @end diff --git a/sope-core/NGExtensions/Version b/sope-core/NGExtensions/Version index f29e845e..4fd1a360 100644 --- a/sope-core/NGExtensions/Version +++ b/sope-core/NGExtensions/Version @@ -1,6 +1,6 @@ # version -SUBMINOR_VERSION:=161 +SUBMINOR_VERSION:=162 # v4.3.115 requires libFoundation v1.0.59 # v4.2.72 requires libEOControl v4.2.39 -- 2.39.5