clsPtree.cpp
3.3 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
/**************************************************************************
* file: clsPtree.cpp
* Author: qingxiongf
* Date: 2021-12-29 16:52:23
* Email: qingxiongf@chinadci.com
* copyright: 广州城市信息研究所有限公司
***************************************************************************/
#include "clsPtree.h"
#include <stdarg.h>
#include <string.h>
#include "clsUtil.h"
namespace DmapCore_30
{
void clsPtree::ParseEnum(const char *name, boost::property_tree::ptree& pt, int v, string a1, string a2 , string a3, string a4, string a5, string a6, string a7, string a8, string a9, string a10, string a11, string a12, string a13, string a14, string a15, string a16)
{
string vstring = a1;
switch (v)
{
case 0: vstring = a1; break;
case 1: vstring = a2; break;
case 2: vstring = a3; break;
case 3: vstring = a4; break;
case 4: vstring = a5; break;
case 5: vstring = a6; break;
case 6: vstring = a7; break;
case 7: vstring = a8; break;
case 8: vstring = a9; break;
case 9: vstring = a10; break;
case 10: vstring = a11; break;
case 11: vstring = a12; break;
case 12: vstring = a13; break;
case 13: vstring = a14; break;
case 14: vstring = a15; break;
case 15: vstring = a16; break;
}
std::string ptname = "<xmlattr>.";
ptname += name;
pt.add(ptname, vstring);
}
void clsPtree::PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, string &v)
{
std::string ptname = "<xmlattr>.";
ptname += name;
pt.add(ptname, v);
}
void clsPtree::PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, bool &v)
{
std::string ptname = "<xmlattr>.";
ptname += name;
pt.add(ptname, v?"true":"false");
}
void clsPtree::PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, double &v)
{
std::string ptname = "<xmlattr>.";
ptname += name;
pt.add(ptname, v);
}
void clsPtree::PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, int &v)
{
std::string ptname = "<xmlattr>.";
ptname += name;
pt.add(ptname, v);
}
void clsPtree::PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, long &v)
{
std::string ptname = "<xmlattr>.";
ptname += name;
pt.add(ptname, v);
}
void clsPtree::PtreeAttrParseColor(const char *name, const char *name2, boost::property_tree::ptree &pt, unsigned int &iColor)
{
string sColor = "", sTransparency = "";
int a = (int)(((unsigned char *)(&iColor))[3]);
int r = (int)(((unsigned char *)(&iColor))[2]);
int g = (int)(((unsigned char *)(&iColor))[1]);
int b = (int)(((unsigned char *)(&iColor))[0]);
//char s1[500], s2[500];
//StringHelp::fmt(s1, "%d,%d,%d", r, g, b);
//StringHelp::fmt(s2, "%lf", a / 255.0);
sColor = clsUtil::fmt("%d,%d,%d", r, g, b);
sTransparency = clsUtil::fmt("%.2f", a / 255.0);
std::string ptname = "<xmlattr>.";
pt.add(ptname + name, sColor);
pt.add(ptname + name2, sTransparency);
}
} // namespace DmapDll