/*
 *	Filename: RegExSyntaxFormatter.m
 *	Created : Tue Jan 21 14:36:39 1997
 *	Author  : Vince DeMarco
 *	LastEditDate Was "Tue Jan 21 15:07:43 1997"
 */

#import "RegExSyntaxFormatter.h"

#import <Foundation/Foundation.h>
#import <regex/RegEx.h>

@implementation RegExSyntaxFormatter

- (NSString *)stringForObjectValue:(id)anObject
{
    if ([anObject isKindOfClass:[RegEx class]]){
	return [anObject pattern];
    }else{
	return anObject;
    }
}

- (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString **)error
{
    if (string && ![string isEqualToString:@""]) {
	if ([RegEx validRegexPattern:string]){
	    if (anObject){
		*anObject = [RegEx regexWithPattern:string];
	    }
	    return YES;
	}else{
	    return NO;
	}
    }
    return YES;
}

@end
