summaryrefslogtreecommitdiffabout
path: root/pumpkin/IPTransformer.m
Side-by-side diff
Diffstat (limited to 'pumpkin/IPTransformer.m') (more/less context) (show whitespace changes)
-rw-r--r--pumpkin/IPTransformer.m21
1 files changed, 21 insertions, 0 deletions
diff --git a/pumpkin/IPTransformer.m b/pumpkin/IPTransformer.m
new file mode 100644
index 0000000..2307b05
--- a/dev/null
+++ b/pumpkin/IPTransformer.m
@@ -0,0 +1,21 @@
+
+#import "IPTransformer.h"
+
+#include <arpa/inet.h>
+
+@implementation IPTransformer
+
++(Class)transformedValueClass { return [NSString class]; }
++(BOOL)allowsReverseTransformation { return YES; }
+-(id)transformedValue:(id)value {
+ if(value &&
+ [value respondsToSelector:@selector(UTF8String)]
+ && inet_addr([value UTF8String])!=INADDR_NONE )
+ return value;
+ return nil;
+}
+-(id)reverseTransformedValue:(id)value {
+ return [self transformedValue:value];
+}
+
+@end \ No newline at end of file