-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
89 lines (78 loc) · 2.32 KB
/
main.cpp
File metadata and controls
89 lines (78 loc) · 2.32 KB
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
80
81
82
83
84
85
86
87
88
89
#include "tinyxml2.h"
#include "template.h"
#include "test.h"
#include <stdio.h>
#include <iostream>
#include "lua.hpp"
#include "lauxlib.h"
#include "lualib.h"
using namespace std;
using namespace tinyxml2;
int main()
{
if (!xml::xmlparser.load())
{
std::cout << "加载失败" << std::endl;
return 1;
}
std::cout << "------------------------- C++ ------------------------------------" << std::endl;
for (auto &v : xml::xmlparser.test1)
{
std::cout << v.second.t1v << " " << v.second.t2v << " " << v.second.t3v << std::endl;
}
for (auto &v : xml::xmlparser.test2)
{
std::cout << v.id << " " << v.name << std::endl;
std::cout << "------" << std::endl;
for(xml::XMLPARSER::TEST2::TESTN_ConstIt it = v.testn.cbegin(); it != v.testn.cend(); ++it)
{
std::cout << it->second.id << " " << it->second.name << std::endl << std::endl;
}
}
std::cout << xml::xmlparser.test3.num1 << " " << xml::xmlparser.test3.num2 << " " << xml::xmlparser.test3.num3 << std::endl;
if (!xml::test.load())
{
std::cout << "加载失败" << std::endl;
return 1;
}
for (auto &v : xml::test.skill)
{
std::cout << v.second.id << " " << v.second.name << std::endl;
}
std::cout << "----------------------------LUA---------------------------------------" << std::endl;
lua_State *L = luaL_newstate();
luaL_openlibs(L);
xml::lua_xmlparser.doLoad2luaState(L);
xml::lua_test.doLoad2luaState(L);
luaL_dofile(L, "./luadir/test.lua");
/*XMLDocument doc;
int ret = 0;
if((ret = doc.LoadFile("./xml/template.xml")) != XML_SUCCESS) {
std::cout << "error" << std::endl;
return false;
}
const XMLElement *ele = NULL;
ele = doc.FirstChildElement("xmlparser");
const XMLAttribute* attri = NULL;
attri = ele->FindAttribute("version");
std::cout << attri->Value() << std::endl;
const XMLElement *node=ele->FirstChildElement("test2");
const XMLElement *node_end=ele->LastChildElement("test2");
while(true)
{
if (strcmp(node->Name(), "test2") != 0)
{
node = node->NextSiblingElement();
continue;
}
std::cout << node->Name() << std::endl;
const XMLAttribute* attri = NULL;
attri = node->FindAttribute("id");
std::cout << attri->Value() << std::endl;
attri = node->FindAttribute("name");
std::cout << attri->Value() << std::endl;
if (node == node_end) break;
node = node->NextSiblingElement();
}*/
return 0;
}