mirror of https://github.com/snes9xgit/snes9x.git
Don't use a magic depth number for attributes.
This commit is contained in:
parent
cb7602263f
commit
abed48e2d0
6
bml.cpp
6
bml.cpp
|
@ -7,6 +7,7 @@
|
|||
|
||||
bml_node::bml_node()
|
||||
{
|
||||
type = CHILD;
|
||||
depth = -1;
|
||||
}
|
||||
|
||||
|
@ -181,7 +182,8 @@ static void bml_parse_attr(bml_node &node, char **data)
|
|||
n.name = trim(std::string(p, len));
|
||||
p += len;
|
||||
bml_parse_data(n, &p);
|
||||
n.depth = bml_attr_type;
|
||||
n.depth = node.depth + 1;
|
||||
n.type = bml_node::CHILD;
|
||||
node.child.push_back(n);
|
||||
}
|
||||
|
||||
|
@ -218,7 +220,7 @@ static void bml_print_node(bml_node &node, int depth)
|
|||
else
|
||||
printf (": %s", node.data.c_str());
|
||||
}
|
||||
for (i = 0; i < (int) node.child.size () && node.child[i].depth == bml_attr_type; i++)
|
||||
for (i = 0; i < (int) node.child.size () && node.child[i].type == bml_node::CHILD; i++)
|
||||
{
|
||||
if (!node.child[i].name.empty())
|
||||
{
|
||||
|
|
9
bml.h
9
bml.h
|
@ -3,21 +3,24 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
const int bml_attr_type = -2;
|
||||
|
||||
struct bml_node
|
||||
{
|
||||
enum node_type {
|
||||
CHILD,
|
||||
ATTRIBUTE
|
||||
};
|
||||
|
||||
bml_node();
|
||||
bool parse_file(const char *filename);
|
||||
void parse(char *buffer);
|
||||
bml_node *find_subnode(std::string name);
|
||||
void print();
|
||||
|
||||
static const int bml_attr_type = -2;
|
||||
std::string name;
|
||||
std::string data;
|
||||
int depth;
|
||||
std::vector<bml_node> child;
|
||||
node_type type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue