]> err.no Git - sope/blob - sope-ical/NGiCal/NGVCardCategories.m
more work on vCard parsing
[sope] / sope-ical / NGiCal / NGVCardCategories.m
1 /*
2   Copyright (C) 2005 Helge Hess
3
4   This file is part of SOPE.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21
22 #include "NGVCardCategories.h"
23 #include "common.h"
24
25 @implementation NGVCardCategories
26
27 - (void)dealloc {
28   [self->categories release];
29   [super dealloc];
30 }
31
32 /* accessors */
33
34 - (NSArray *)categories {
35   return self->categories;
36 }
37
38 /* values */
39
40 - (NSString *)stringValue {
41   return [self vCardString];
42 }
43
44 - (NSString *)xmlString {
45   return [[self stringValue] stringByEscapingXMLString];
46 }
47
48 - (NSString *)vCardString {
49   return [[self categories] componentsJoinedByString:@","];
50 }
51
52 - (id)propertyList {
53   return [self categories];
54 }
55
56 - (NSArray *)asArray {
57   return self->categories;
58 }
59
60 /* fake being an array */
61
62 - (id)objectAtIndex:(unsigned)_idx {
63   return [self->categories objectAtIndex:_idx];
64 }
65 - (unsigned)count {
66   return [self->categories count];
67 }
68
69 /* fake being a string */
70
71 - (unichar)characterAtIndex:(unsigned)_idx {
72   return [[self stringValue] characterAtIndex:_idx];
73 }
74 - (unsigned)length {
75   return [[self stringValue] length];
76 }
77
78 /* NSCoding */
79
80 - (void)encodeWithCoder:(NSCoder *)_coder {
81   [super encodeWithCoder:_coder];
82   [_coder encodeObject:self->categories];
83 }
84 - (id)initWithCoder:(NSCoder *)_coder {
85   if ((self = [super initWithCoder:_coder]) != nil) {
86     self->categories = [[_coder decodeObject] copy];
87   }
88   return self;
89 }
90
91 /* description */
92
93 - (void)appendAttributesToDescription:(NSMutableString *)_ms {
94   [super appendAttributesToDescription:_ms];
95   [_ms appendFormat:@" vcard=%@", [self vCardString]];
96 }
97
98 @end /* NGVCardCategories */