]> err.no Git - sope/blob - sope-ical/NGiCal/NGVCardSimpleValue.m
added class version checks
[sope] / sope-ical / NGiCal / NGVCardSimpleValue.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 "NGVCardSimpleValue.h"
23 #include "common.h"
24
25 @implementation NGVCardSimpleValue
26
27 + (int)version {
28   return [super version] + 0 /* v0 */;
29 }
30 + (void)initialize {
31   NSAssert2([super version] == 0,
32             @"invalid superclass (%@) version %i !",
33             NSStringFromClass([self superclass]), [super version]);
34 }
35
36 - (id)initWithValue:(NSString *)_value group:(NSString *)_group 
37   types:(NSArray *)_types arguments:(NSDictionary *)_a
38 {
39   if ((self = [super initWithGroup:_group types:_types arguments:_a]) != nil) {
40     self->value = [_value copy];
41   }
42   return self;
43 }
44
45 - (id)initWithGroup:(NSString *)_group types:(NSArray *)_types
46   arguments:(NSDictionary *)_a
47 {
48   return [self initWithValue:nil group:_group types:_types arguments:_a];
49 }
50 - (id)init {
51   return [self initWithValue:nil group:nil types:nil arguments:nil];
52 }
53
54 - (void)dealloc {
55   [self->value release];
56   [super dealloc];
57 }
58
59 /* values */
60
61 - (NSString *)stringValue {
62   return self->value;
63 }
64
65 - (id)propertyList {
66   return [self stringValue];
67 }
68
69 /* fake being a string */
70
71 - (unichar)characterAtIndex:(unsigned)_idx {
72   return [self->value characterAtIndex:_idx];
73 }
74 - (unsigned)length {
75   return [self->value length];
76 }
77
78 /* NSCoding */
79
80 - (void)encodeWithCoder:(NSCoder *)_coder {
81   [super encodeWithCoder:_coder];
82   [_coder encodeObject:self->value];
83 }
84 - (id)initWithCoder:(NSCoder *)_coder {
85   if ((self = [super initWithCoder:_coder]) != nil) {
86     self->value = [[_coder decodeObject] copy];
87   }
88   return self;
89 }
90
91 /* description */
92
93 - (void)appendAttributesToDescription:(NSMutableString *)_ms {
94   if (self->value != nil) [_ms appendFormat:@" value='%@'", self->value];
95   [super appendAttributesToDescription:_ms];
96 }
97
98 @end /* NGVCardSimpleValue */