2007-01-31 18:11:29 +01:00
|
|
|
/* CardElement.h - this file is part of SOPE
|
|
|
|
*
|
2014-09-12 14:34:15 +02:00
|
|
|
* Copyright (C) 2006-2014 Inverse inc.
|
2007-01-31 18:11:29 +01:00
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
2014-09-12 14:34:15 +02:00
|
|
|
* This file is distributed in the hope that it will be useful,]
|
2007-01-31 18:11:29 +01:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CARDELEMENT_H
|
|
|
|
#define CARDELEMENT_H
|
|
|
|
|
|
|
|
#import <Foundation/NSObject.h>
|
|
|
|
|
|
|
|
@class NSArray;
|
|
|
|
@class NSDictionary;
|
|
|
|
@class NSMutableArray;
|
|
|
|
@class NSMutableDictionary;
|
|
|
|
@class NSString;
|
|
|
|
|
|
|
|
@class CardGroup;
|
|
|
|
|
2007-11-18 10:43:52 +01:00
|
|
|
@interface CardElement : NSObject <NSCopying, NSMutableCopying>
|
2007-01-31 18:11:29 +01:00
|
|
|
{
|
|
|
|
NSString *tag;
|
2011-11-14 17:07:04 +01:00
|
|
|
NSMutableDictionary *values;
|
2007-01-31 18:11:29 +01:00
|
|
|
NSMutableDictionary *attributes;
|
|
|
|
NSString *group;
|
|
|
|
CardGroup *parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (id) elementWithTag: (NSString *) aTag;
|
|
|
|
|
|
|
|
+ (id) simpleElementWithTag: (NSString *) aTag
|
|
|
|
value: (NSString *) aValue;
|
|
|
|
|
|
|
|
+ (id) simpleElementWithTag: (NSString *) aTag
|
|
|
|
singleType: (NSString *) aType
|
|
|
|
value: (NSString *) aValue;
|
|
|
|
|
|
|
|
- (void) setParent: (CardGroup *) aParent;
|
2007-11-18 10:43:52 +01:00
|
|
|
- (id) parent;
|
2007-01-31 18:11:29 +01:00
|
|
|
|
|
|
|
- (void) setTag: (NSString *) aTag;
|
2011-11-14 17:07:04 +01:00
|
|
|
- (NSString *) tag;
|
2007-01-31 18:11:29 +01:00
|
|
|
|
|
|
|
- (void) setGroup: (NSString *) aGroup;
|
|
|
|
- (NSString *) group;
|
|
|
|
|
2011-11-14 17:07:04 +01:00
|
|
|
- (BOOL) isVoid;
|
2010-10-27 18:24:29 +02:00
|
|
|
|
2011-11-14 17:07:04 +01:00
|
|
|
- (void) setValues: (NSMutableDictionary *) newValues;
|
|
|
|
- (NSMutableDictionary *) values;
|
|
|
|
|
|
|
|
/* ELEM:...;value1,value2,...;... */
|
|
|
|
- (void) setValues: (NSMutableArray *) newValues
|
|
|
|
atIndex: (NSUInteger) idx
|
|
|
|
forKey: (NSString *) key;
|
|
|
|
|
|
|
|
/* ELEM:...;value;... */
|
|
|
|
- (void) setSingleValue: (NSString *) newValue
|
|
|
|
atIndex: (NSUInteger) idx
|
|
|
|
forKey: (NSString *) key;
|
|
|
|
/* ELEM:value */
|
|
|
|
- (void) setSingleValue: (NSString *) newValue
|
|
|
|
forKey: (NSString *) key;
|
|
|
|
|
|
|
|
- (NSMutableArray *) valuesForKey: (NSString *) key;
|
|
|
|
- (NSMutableArray *) valuesAtIndex: (NSUInteger) idx
|
|
|
|
forKey: (NSString *) key;
|
|
|
|
|
|
|
|
/* This joins all subvalues with "," and ordered values with ";". Handy for
|
|
|
|
retrieving data from clients which don't escape their data properly. */
|
|
|
|
- (NSString *) flattenedValuesForKey: (NSString *) key;
|
|
|
|
- (NSString *) flattenedValueAtIndex: (NSUInteger) idx
|
|
|
|
forKey: (NSString *) key;
|
|
|
|
|
|
|
|
/* attribute values */
|
2007-01-31 18:11:29 +01:00
|
|
|
- (void) setValue: (unsigned int) anInt
|
|
|
|
ofAttribute: (NSString *) anAttribute
|
|
|
|
to: (NSString *) aValue;
|
|
|
|
- (NSString *) value: (unsigned int) anInt
|
|
|
|
ofAttribute: (NSString *) anAttribute;
|
|
|
|
|
|
|
|
- (void) addAttribute: (NSString *) anAttribute
|
|
|
|
value: (NSString *) aValue;
|
|
|
|
- (void) addAttributes: (NSDictionary *) someAttributes;
|
|
|
|
- (void) removeValue: (NSString *) aValue
|
|
|
|
fromAttribute: (NSString *) anAttribute;
|
2011-11-14 17:07:04 +01:00
|
|
|
- (NSMutableDictionary *) attributes;
|
2007-01-31 18:11:29 +01:00
|
|
|
- (BOOL) hasAttribute: (NSString *) aType
|
|
|
|
havingValue: (NSString *) aValue;
|
|
|
|
|
2011-11-14 17:07:04 +01:00
|
|
|
- (void) addType: (NSString *) aType;
|
2007-01-31 18:11:29 +01:00
|
|
|
|
2012-04-23 17:17:02 +02:00
|
|
|
/* rendering */
|
2012-04-19 04:49:25 +02:00
|
|
|
- (NSArray *) orderOfAttributeKeys;
|
|
|
|
- (NSArray *) orderOfValueKeys;
|
2007-01-31 18:11:29 +01:00
|
|
|
- (NSString *) versitString;
|
|
|
|
|
|
|
|
- (CardGroup *) searchParentOfClass: (Class) parentClass;
|
|
|
|
|
2012-04-23 17:17:02 +02:00
|
|
|
/* conversion */
|
2008-08-05 03:46:41 +02:00
|
|
|
- (id) elementWithClass: (Class) elementClass;
|
|
|
|
|
2012-04-23 17:17:02 +02:00
|
|
|
/* copy */
|
2007-01-31 18:11:29 +01:00
|
|
|
- (void) setAttributesAsCopy: (NSMutableDictionary *) someAttributes;
|
2008-08-05 03:46:41 +02:00
|
|
|
- (NSMutableArray *) deepCopyOfArray: (NSArray *) oldArray
|
|
|
|
withZone: (NSZone *) aZone;
|
|
|
|
- (NSMutableDictionary *) deepCopyOfDictionary: (NSDictionary *) oldDictionary
|
|
|
|
withZone: (NSZone *) aZone;
|
|
|
|
|
2007-01-31 18:11:29 +01:00
|
|
|
@end
|
|
|
|
|
2007-06-07 18:19:02 +02:00
|
|
|
#define IS_EQUAL(a,b,sel) \
|
|
|
|
_iCalSafeCompareObjects (a, b, @selector(sel))
|
|
|
|
|
|
|
|
static __inline__ BOOL _iCalSafeCompareObjects(id a, id b, SEL comparator)
|
|
|
|
{
|
|
|
|
id va = a;
|
|
|
|
id vb = b;
|
|
|
|
BOOL (*compm)(id, SEL, id);
|
|
|
|
|
|
|
|
if((!va && vb) || (va && !vb))
|
|
|
|
return NO;
|
|
|
|
else if(va == vb)
|
|
|
|
return YES;
|
|
|
|
compm = (BOOL (*)( id, SEL, id)) [va methodForSelector: comparator];
|
|
|
|
|
|
|
|
return compm(va, comparator, vb);
|
|
|
|
}
|
|
|
|
|
2007-01-31 18:11:29 +01:00
|
|
|
#endif /* CARDELEMENT_H */
|