-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnionParser.cs
52 lines (50 loc) · 1.42 KB
/
UnionParser.cs
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
using System;
using System.Xml;
using System.Collections.Generic;
using VulkanParser.objetos;
namespace VulkanParser
{
/// <summary>
/// Description of UnionParser.
/// </summary>
public static class UnionParser
{
public static Dictionary<string, Union> unions;
public static void Parse(XmlDocument xdoc)
{
unions = new Dictionary<string, Union>();
XmlNodeList xml_unions = xdoc.SelectNodes("/registry/types/type[@category='union']");
if (xml_unions.Count > 0)
{
for (int i=0;i<xml_unions.Count;i++)
{
XmlNode n_union = xml_unions[i];
string s_name = n_union.Attributes["name"].Value;
Union un0 = new Union();
un0.Name = s_name;
XmlNodeList miembros = n_union.SelectNodes("member");
if (miembros.Count > 0)
{
for (int m=0; m<miembros.Count;m++)
{
unionmembers unm0 = new unionmembers();
string s_mname = miembros[m].SelectSingleNode("name").InnerText;
string s_mtipo = miembros[m].SelectSingleNode("type").InnerText;
unm0.name = s_mname;
unm0.Type = s_mtipo;
if (miembros[m].InnerText.Contains("["))
{
//es array con máximo.
string scant = miembros[m].InnerText.Split('[')[1];
scant = scant.Split(']')[0];
unm0.cant = scant;
}
un0.members.Add(s_mname, unm0);
}
}
unions.Add(s_name, un0);
}
}
}
}
}