-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathIntel.cpp
More file actions
89 lines (80 loc) · 2.2 KB
/
Copy pathIntel.cpp
File metadata and controls
89 lines (80 loc) · 2.2 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 "Intel.h"
#include <string>
#include <cassert>
#include "StringFuncs.h"
Intel::Intel() : m_dOvercast(-1), m_dOvercastWanted(-1), m_dFog(-1), m_dFogWanted(-1),
m_hour(-1), m_minute(-1), m_month(-1), m_year(-1), m_day(-1)
{
}
void Intel::DeserializeSQM(std::istream &in)
{
std::string strLine;
std::getline(in, strLine);
assert(strLine != "{");
unsigned short scope = 1;
while(scope != 0)
{
std::getline(in, strLine);
scope += CharCount(strLine, '{');
scope -= CharCount(strLine, '}');
size_t eqPos = strLine.find('=');
std::string strCmd = RemoveWhitespace(strLine.substr(0, eqPos));
std::string strArg = strLine.substr(eqPos+1, strLine.size()-1);
if(strCmd == "startWeather")
{
m_dOvercast = atof(strArg.c_str());
}
else if(strCmd == "forecastWeather")
{
m_dOvercastWanted = atof(strArg.c_str());
}
else if(strCmd == "year")
{
m_year = atoi(strArg.c_str());
}
else if(strCmd == "month")
{
m_month = atoi(strArg.c_str());
}
else if(strCmd == "day")
{
m_day = atoi(strArg.c_str());
}
else if(strCmd == "hour")
{
m_hour = atoi(strArg.c_str());
}
else if(strCmd == "minute")
{
m_minute = atoi(strArg.c_str());
}
}
}
void Intel::SerializeBiEdi(std::ostream &out)
{
out << "class _intel_1" << std::endl
<< "{" << std::endl
<< " objectType=\"intel\";" << std::endl
<< " class Arguments" << std::endl
<< " {" << std::endl;
if(m_dOvercast != -1)
out << " OVERCAST=\"" << m_dOvercast << "\";" << std::endl;
if(m_dOvercastWanted != -1)
out << " OVERCAST_WANTED=\"" << m_dOvercastWanted << "\";" << std::endl;
if(m_dFog != -1)
out << " FOG=\"" << m_dFog << "\";" << std::endl;
if(m_dFogWanted != -1)
out << " FOG_WANTED=\"" << m_dFogWanted << "\";" << std::endl;
if(m_year != -1)
out << " YEAR=\"" << m_year << "\";" << std::endl;
if(m_month != -1)
out << " MONTH=\"" << (unsigned int)m_month << "\";" << std::endl;
if(m_day != -1)
out << " DAY=\"" << (unsigned int)m_day << "\";" << std::endl;
if(m_hour != -1)
out << " HOUR=\"" << (unsigned int)m_hour << "\";" << std::endl;
if(m_minute != -1)
out << " MINUTE=\"" << (unsigned int)m_minute << "\";" << std::endl;
out << " };" << std::endl;
out << "};" << std::endl;
}