Browse Source

hide json in pdns slave config

develop
Robin Thoni 9 years ago
parent
commit
364daaa736
2 changed files with 17 additions and 12 deletions
  1. 12
    11
      src/DataAccess/PdnsSlaveConfig.cpp
  2. 5
    1
      src/DataAccess/PdnsSlaveConfig.h

+ 12
- 11
src/DataAccess/PdnsSlaveConfig.cpp View File

4
 
4
 
5
 #include <fstream>
5
 #include <fstream>
6
 #include <iostream>
6
 #include <iostream>
7
+# include <json/json.h>
7
 #include "PdnsSlaveConfig.h"
8
 #include "PdnsSlaveConfig.h"
8
 
9
 
9
 PdnsSlaveConfig::PdnsSlaveConfig(const std::string &filePath)
10
 PdnsSlaveConfig::PdnsSlaveConfig(const std::string &filePath)
16
     std::ifstream file(_filePath);
17
     std::ifstream file(_filePath);
17
     if (!file)
18
     if (!file)
18
         return false;
19
         return false;
20
+    Json::Value root;
19
     try
21
     try
20
     {
22
     {
21
-        Json::Value root;
22
         file >> root;
23
         file >> root;
23
         file.close();
24
         file.close();
24
-        if (!readString(root, "dhcpd-file", _dhcpdFilePath))
25
-            return false;
26
-        if (!readString(root, "dhcpd-template", _dhcpdTemplatePath))
27
-            return false;
28
-        if (!readString(root, "hosts-file", _hostsPath))
29
-            return false;
30
-        if (!readSqlConfiguration(root, "master", _masterConfig))
31
-            return false;
32
-        if (!readSqlConfiguration(root, "slave", _slaveConfig))
33
-            return false;
34
     }
25
     }
35
     catch (...)
26
     catch (...)
36
     {
27
     {
37
         file.close();
28
         file.close();
38
         return false;
29
         return false;
39
     }
30
     }
31
+    if (!readString(root, "dhcpd-file", _dhcpdFilePath))
32
+        return false;
33
+    if (!readString(root, "dhcpd-template", _dhcpdTemplatePath))
34
+        return false;
35
+    if (!readString(root, "hosts-file", _hostsPath))
36
+        return false;
37
+    if (!readSqlConfiguration(root, "master", _masterConfig))
38
+        return false;
39
+    if (!readSqlConfiguration(root, "slave", _slaveConfig))
40
+        return false;
40
 
41
 
41
     return true;
42
     return true;
42
 }
43
 }

+ 5
- 1
src/DataAccess/PdnsSlaveConfig.h View File

6
 #define PDNS_SLAVE_PDNSSLAVECONFIG_H
6
 #define PDNS_SLAVE_PDNSSLAVECONFIG_H
7
 
7
 
8
 # include <string>
8
 # include <string>
9
-# include <json/json.h>
10
 # include "DBO/SqlConfiguration.h"
9
 # include "DBO/SqlConfiguration.h"
11
 
10
 
11
+namespace Json
12
+{
13
+    class Value;
14
+}
15
+
12
 class PdnsSlaveConfig
16
 class PdnsSlaveConfig
13
 {
17
 {
14
 public:
18
 public:

Loading…
Cancel
Save