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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Wind River Systems - Modified for new DSF Reference Implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.mi.service.command.output;
/**
* GDB/MI var-list-children
* -var-list-children var2
* ^done,numchild="6",children={child={name="var2.0",exp="0",numchild="0",type="char"},child={name="var2.1",exp="1",numchild="0",type="char"},child={name="var2.2",exp="2",numchild="0",type="char"},child={name="var2.3",exp="3",numchild="0",type="char"},child={name="var2.4",exp="4",numchild="0",type="char"},child={name="var2.5",exp="5",numchild="0",type="char"}}
*
*/
public class MIVar {
String name = ""; //$NON-NLS-1$
String type = ""; //$NON-NLS-1$
String exp = ""; //$NON-NLS-1$
int numchild;
public MIVar(String n, int num, String t) {
name = n;
numchild = num;
type = t;
}
public MIVar(MITuple tuple) {
parse(tuple);
}
public String getVarName() {
return name;
}
public String getType() {
return type;
}
public int getNumChild() {
return numchild;
}
public String getExp() {
return exp;
}
void parse(MITuple tuple) {
MIResult[] results = tuple.getMIResults();
for (int i = 0; i < results.length; i++) {
String var = results[i].getVariable();
MIValue value = results[i].getMIValue();
String str = ""; //$NON-NLS-1$
if (value != null && value instanceof MIConst) {
str = ((MIConst)value).getCString();
}
if (var.equals("numchild")) { //$NON-NLS-1$
try {
numchild = Integer.parseInt(str.trim());
} catch (NumberFormatException e) {
}
} else if (var.equals("name")) { //$NON-NLS-1$
name = str;
} else if (var.equals("type")) { //$NON-NLS-1$
type = str;
} else if (var.equals("exp")) { //$NON-NLS-1$
exp = str;
}
}
}
}
|