3 * Copyright (c) 2007 - 2010, 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>
19 #import "AppDelegate.h"
21 @implementation NSXMLElement (GDBpAdditions
)
24 * Return's the property's full name
28 return [[self attributeForName
:@
"fullname"] stringValue
];
32 * Return's the property's name from the attributes list
36 return [[self attributeForName
:@
"name"] stringValue
];
40 * Returns whether or not this node has any children
44 return ([[[self attributeForName
:@
"children"] stringValue
] intValue
] == 0);
48 * Override children so we can fetch more depth as needed
52 NSArray
* children
= [self children
];
53 if (![self isLeaf
] && [children count
] < 1) {
54 // If this node has children but they haven't been loaded from the backend,
55 // request them asynchronously.
56 [[AppDelegate instance
].debugger fetchProperty
:[self fullname
] forNode
:self];
62 * Returns the value of the property
66 // not a leaf, so don't display any value
72 // base64 encoded data
73 if ([[[self attributeForName
:@
"encoding"] stringValue
] isEqualToString
:@
"base64"])
75 const char* str
= [[self stringValue
] UTF8String
];
76 int strlen
= [[self stringValue
] length
];
81 if (!base64_decode_alloc(str
, strlen
, &data
, &datalen
))
82 NSLog(@
"error in converting %@ from base64", self);
87 ret
= [NSString stringWithUTF8String
:data
];
94 // just a normal string
95 return [self stringValue
];
99 * Returns the type of variable this is
103 NSXMLNode
* className
= [self attributeForName
:@
"classname"];
104 NSString
* type
= [[self attributeForName
:@
"type"] stringValue
];
105 if (className
!= nil)
107 return [NSString stringWithFormat
:@
"%@ (%@)", [className stringValue
], type
];