-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobalconfig.h
More file actions
112 lines (89 loc) · 2.06 KB
/
globalconfig.h
File metadata and controls
112 lines (89 loc) · 2.06 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef GLOBALCONFIG_H
#define GLOBALCONFIG_H
#include <QString>
#include <QDir>
#include <QMap>
#include <QVector>
#include <QTextCodec>
#include <QDebug>
#include <regex>
extern "C"
{
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
}
//服务器
struct sServerInfo
{
QString name;
QString ip;
int port;
friend QDebug& operator<<(QDebug& out, const sServerInfo& info)
{
out << info.name << info.ip << info.port;
return out;
}
};
//项目
struct sProgram
{
QString sProgramName;
QVector<sServerInfo> serverList;
friend QDebug& operator<<(QDebug& out, const sProgram& info)
{
out << info.sProgramName << info.serverList;
return out;
}
};
typedef QMap <QString, sProgram> qMapPrograms;
class MainWindow;
class GlobalConfig
{
private:
GlobalConfig();
public:
~GlobalConfig() {};
static GlobalConfig* getInstance(){
if (m_instance == nullptr)
{
m_instance = new GlobalConfig();
}
return m_instance;
}
// friend QDebug& operator<<(QDebug out, const qMapPrograms& info)
// {
// qMapPrograms::const_iterator it;
// for(it = info.begin(); it != info.end(); ++it)
// {
// out << it.key() << it.value();
// }
// return out;
// }
bool LoadConfig(QString fileName);
void ParseLuaTable(lua_State* L);
void SetMainWindow(MainWindow* mainWindow)
{
m_mainWindow = mainWindow;
}
MainWindow* GetMainWindow()
{
return m_mainWindow;
}
const qMapPrograms* GetProgramData()
{
return &m_programs;
}
qMapPrograms::const_iterator GetProgramInfoList(QString& sProgram)
{
return m_programs.find(sProgram);
}
std::string doubleToString(double price);
bool CheckStrIsCorrectType(QString str, int nType);
int PickStrALuaValueType(QString str);
private:
static GlobalConfig* m_instance;
qMapPrograms m_programs;
MainWindow* m_mainWindow;
};
#endif // GLOBALCONFIG_H