]> err.no Git - scalable-opengroupware.org/blob - SOPE/NGCards/CardElement.h
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1178 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / SOPE / NGCards / CardElement.h
1 /* CardElement.h - this file is part of SOPE
2  *
3  * Copyright (C) 2006 Inverse groupe conseil
4  *
5  * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
6  *
7  * This file is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * This file is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #ifndef CARDELEMENT_H
24 #define CARDELEMENT_H
25
26 #import <Foundation/NSObject.h>
27
28 @class NSArray;
29 @class NSDictionary;
30 @class NSMutableArray;
31 @class NSMutableDictionary;
32 @class NSString;
33
34 @class CardGroup;
35
36 @interface CardElement : NSObject <NSCopying>
37 {
38   NSString *tag;
39   NSMutableArray *values;
40   NSMutableDictionary *attributes;
41   NSString *group;
42   CardGroup *parent;
43 }
44
45 + (id) elementWithTag: (NSString *) aTag;
46
47 + (id) simpleElementWithTag: (NSString *) aTag
48                       value: (NSString *) aValue;
49
50 + (id) simpleElementWithTag: (NSString *) aTag
51                  singleType: (NSString *) aType
52                       value: (NSString *) aValue;
53
54 + (id) elementWithTag: (NSString *) aTag
55            attributes: (NSDictionary *) someAttributes
56                values: (NSArray *) someValues;
57
58 - (void) setParent: (CardGroup *) aParent;
59 - (CardGroup *) parent;
60
61 - (void) setTag: (NSString *) aTag;
62
63 - (void) setGroup: (NSString *) aGroup;
64 - (NSString *) group;
65
66 - (void) addValue: (NSString *) aValue;
67 - (void) addValues: (NSArray *) someValues;
68
69 - (void) setValue: (unsigned int) anInt
70                to: (NSString *) aValue;
71 - (NSString *) value: (unsigned int) anInt;
72
73 - (void) setNamedValue: (NSString *) aValueName
74                     to: (NSString *) aValue;
75 - (NSString *) namedValue: (NSString *) aValueName;
76
77 - (void) setValue: (unsigned int) anInt
78       ofAttribute: (NSString *) anAttribute
79                to: (NSString *) aValue;
80 - (NSString *) value: (unsigned int) anInt
81          ofAttribute: (NSString *) anAttribute;
82
83 - (void) addAttribute: (NSString *) anAttribute
84                 value: (NSString *) aValue;
85 - (void) addAttributes: (NSDictionary *) someAttributes;
86 - (void) removeValue: (NSString *) aValue
87        fromAttribute: (NSString *) anAttribute;
88
89 - (void) addType: (NSString *) aType;
90
91 - (NSString *) tag;
92 - (NSArray *) values;
93 - (NSDictionary *) attributes;
94 - (BOOL) hasAttribute: (NSString *) aType
95           havingValue: (NSString *) aValue;
96
97 - (BOOL) isVoid;
98
99 - (NSString *) versitString;
100
101 - (CardGroup *) searchParentOfClass: (Class) parentClass;
102
103 - (CardElement *) elementWithClass: (Class) elementClass;
104 - (void) setValuesAsCopy: (NSMutableArray *) someValues;
105 - (void) setAttributesAsCopy: (NSMutableDictionary *) someAttributes;
106
107 @end
108
109 #define IS_EQUAL(a,b,sel) \
110   _iCalSafeCompareObjects (a, b, @selector(sel))
111
112 static __inline__ BOOL _iCalSafeCompareObjects(id a, id b, SEL comparator)
113 {
114   id va = a;
115   id vb = b;
116   BOOL (*compm)(id, SEL, id);
117
118   if((!va && vb) || (va && !vb))
119     return NO;
120   else if(va == vb)
121     return YES;
122   compm = (BOOL (*)( id, SEL, id)) [va methodForSelector: comparator];
123
124   return compm(va, comparator, vb);
125 }
126
127 #endif /* CARDELEMENT_H */