]> err.no Git - sope/blob - sope-ical/NGiCal/NGVCardCategories.m
c87710eb6e51a58ee931be3c35525357abc7187e
[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 "NGVCardValue.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 /* fake being an array */
57
58 - (id)objectAtIndex:(unsigned)_idx {
59   return [self->categories objectAtIndex:_idx];
60 }
61 - (unsigned)count {
62   return [self->categories count];
63 }
64
65 /* fake being a string */
66
67 - (unichar)characterAtIndex:(unsigned)_idx {
68   return [[self stringValue] characterAtIndex:_idx];
69 }
70 - (unsigned)length {
71   return [[self stringValue] length];
72 }
73
74 /* NSCoding */
75
76 - (void)encodeWithCoder:(NSCoder *)_coder {
77   [super encodeWithCoder:_coder];
78   [_coder encodeObject:self->categories];
79 }
80 - (id)initWithCoder:(NSCoder *)_coder {
81   if ((self = [super initWithCoder:_coder]) != nil) {
82     self->categories = [[_coder decodeObject] copy];
83   }
84   return self;
85 }
86
87 @end /* NGVCardCategories */