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)
55 return [[[(AppDelegate
*)[NSApp delegate
] debugger
] connection
] getProperty
:[self fullname
]];
61 * Returns the value of the property
65 // not a leaf, so don't display any value
71 // base64 encoded data
72 if ([[[self attributeForName
:@
"encoding"] stringValue
] isEqualToString
:@
"base64"])
74 const char* str
= [[self stringValue
] UTF8String
];
75 int strlen
= [[self stringValue
] length
];
80 if (!base64_decode_alloc(str
, strlen
, &data
, &datalen
))
81 NSLog(@
"error in converting %@ from base64", self);
86 ret
= [NSString stringWithUTF8String
:data
];
93 // just a normal string
94 return [self stringValue
];
98 * Returns the type of variable this is
102 NSXMLNode
* className
= [self attributeForName
:@
"classname"];
103 NSString
* type
= [[self attributeForName
:@
"type"] stringValue
];
104 if (className
!= nil)
106 return [NSString stringWithFormat
:@
"%@ (%@)", [className stringValue
], type
];