3 * Copyright (c) 2007 - 2008, Blue Static <http://www.bluestatic.org>
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
10 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17 #import <Cocoa/Cocoa.h>
20 @implementation NSXMLElement (NSXMLElementAdditions
)
23 * Return's the property's full name
25 - (NSString
*)fullname
27 return [[self attributeForName
:@
"fullname"] stringValue
];
31 * Return's the property's name from the attributes list
33 - (NSString
*)variable
35 return [[self attributeForName
:@
"name"] stringValue
];
39 * Returns whether or not this node has any children
43 return ([[[self attributeForName
:@
"children"] stringValue
] intValue
] == 0);
47 * Returns the value of the property
51 // not a leaf, so don't display any value
57 // base64 encoded data
58 if ([[[self attributeForName
:@
"encoding"] stringValue
] isEqualToString
:@
"base64"])
60 char *str
= (char *)[[self stringValue
] cStringUsingEncoding
:NSASCIIStringEncoding
];
61 int strlen
= [[self stringValue
] lengthOfBytesUsingEncoding
:NSASCIIStringEncoding
];
66 if (!base64_decode_alloc(str
, strlen
, &data
, &datalen
))
68 NSLog(@
"error in converting %@ to base64", self);
71 NSString
*ret
= [NSString stringWithCString
:data length
:datalen
];
77 // just a normal string
78 return [self stringValue
];
82 * Returns the type of variable this is
86 return [[self attributeForName
:@
"type"] stringValue
];