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