-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigParser.cpp
More file actions
53 lines (45 loc) · 1.21 KB
/
configParser.cpp
File metadata and controls
53 lines (45 loc) · 1.21 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
#include <fstream>
#include "configParser.hpp"
using std::fstream;
using std::ios;
using namespace basefw;
bool configParser::parse(config &Config)
{
bool ret = true;
do
{
fstream fs("config.txt", ios::in);
if(!fs.is_open())
{
ret = false;
LOG_ERROR("cannot open config file!");
break;
}
try
{
string strThreadNum;
fs >> strThreadNum;
std::string::size_type sz;
Config.m_iThreadNum = std::stoi(strThreadNum, &sz);
}
catch(const std::exception& e)
{
std::cerr << e.what() << '\n';
}
LOG_INFO("thread number is " << Config.m_iThreadNum);
string strTempUrl;
Endpoint endpoint;
while(!fs.eof() && fs.good())
{
fs >> strTempUrl;
if(!basefw::string2EndpointPara(strTempUrl, endpoint))
{
continue;
}
Config.m_vecUrl.push_back(endpoint);
LOG_INFO("endpoint: "<< endpoint.strAddr<<" port: "<< endpoint.strPort<<" other para is : "<<endpoint.strOtherPara);
}
fs.close();
} while (0);
return ret;
}