2 Copyright (C) 2005 Helge Hess
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "NGVCardValue.h"
23 #include <NGExtensions/NSString+misc.h>
26 @implementation NGVCardValue
29 [self->group release];
30 [self->types release];
31 [self->arguments release];
43 - (NSDictionary *)arguments {
44 return self->arguments;
47 return [self->types containsObject:@"PREF"];
52 - (NSString *)stringValue {
53 [self logWithFormat:@"ERROR(%s): subclasses should override this method!",
59 return [self stringValue];
62 - (NSString *)xmlString {
63 return [[self stringValue] stringByEscapingXMLString];
66 - (NSString *)vCardString {
67 // TODO: apply proper escaping
68 return [self stringValue];
71 /* misc support methods */
73 - (void)appendXMLTag:(NSString *)_tag value:(NSString *)_val
74 to:(NSMutableString *)_ms
76 [_ms appendString:@"<"];
77 [_ms appendString:_tag];
78 [_ms appendString:@">"];
79 if ([_val isNotNull]) [_ms appendString:[_val stringByEscapingXMLString]];
80 [_ms appendString:@"</"];
81 [_ms appendString:_tag];
82 [_ms appendString:@">"];
85 - (void)appendVCardValue:(NSString *)_val to:(NSMutableString *)_ms {
86 // TODO: properly escape!
87 if ([_val isNotNull]) [_ms appendString:_val];
92 - (id)copyWithZone:(NSZone *)_zone {
93 /* values are considered immutable */
99 - (void)encodeWithCoder:(NSCoder *)_coder {
100 [_coder encodeObject:self->group];
101 [_coder encodeObject:self->types];
102 [_coder encodeObject:self->arguments];
104 - (id)initWithCoder:(NSCoder *)_coder {
105 self->group = [[_coder decodeObject] copy];
106 self->types = [[_coder decodeObject] copy];
107 self->arguments = [[_coder decodeObject] copy];
111 @end /* NGVCardValue */