-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBCXMLElement.h
62 lines (41 loc) · 1.45 KB
/
BCXMLElement.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// BCXMLElement.h
// Caravan
//
// Created by Tom Houpt on 15/3/17.
// Copyright (c) 2015 Tom Houpt. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, BCXMLElementType) {
kBCXMLElementOther = 0,
kBCXMLElementArray = 1,
kBCXMLElementDictionary = 2,
kBCXMLElementString = 3
};
@interface BCXMLElement : NSObject
@property (copy) NSString *name;
@property NSMutableDictionary *attributes;
@property NSObject *value; // either an array or a dictionary
-(id)initWithName:(NSString *)n andAttributes:(NSDictionary *)a;
-(BOOL)isEmpty;
-(BOOL)hasValue;
-(BOOL)hasAttributes;
-(NSString *)attributeForKey:(NSString *)k;
-(BCXMLElementType) type;
/// value can be of class NSMutableArray, NSMutableDictionary, or NSString
-(void)setElementType:(BCXMLElementType)type;
-(NSArray *)array;
-(NSDictionary *)dictionary;
-(NSString *)string;
-(void)addSubElement:(BCXMLElement *)e;
-(BCXMLElement *)elementForKey:(NSString *)n;
-(BCXMLElement *)elementAtIndex:(NSUInteger)i;
-(NSInteger)count; /// length if kBCXMLElementString; -1 if no count value?
-(NSInteger)length; /// same as count; -1 if no count value?
/** return object at bottom of given path of dictionary keys
i.e given path @"dict1/dict2/key"
return [[[self objectForKey:dict1] objectForKey:dict2] objectForKey:key]
return nil if any path keys are not found or are not dictionaries
*/
-(BCXMLElement *) elementAtKeyPath:(NSString *)path;
@end