| |
60 |
60 |
|
| |
61 |
61 |
TConfig& TConfig::operator=(const TConfig& rSrc) |
| |
62 |
62 |
{ |
| |
63 |
63 |
if(this != &rSrc) |
| |
64 |
64 |
*m_pImpl = *rSrc.m_pImpl; |
| |
65 |
65 |
|
| |
66 |
66 |
return *this; |
| |
67 |
67 |
} |
| |
68 |
68 |
|
| |
69 |
69 |
TConfig::~TConfig() |
| |
70 |
70 |
{ |
| |
71 |
71 |
delete m_pImpl; |
| |
72 |
72 |
} |
| |
73 |
73 |
|
| |
74 |
74 |
|
| |
75 |
75 |
void TConfig::Read(PCTSTR pszFile) |
| |
76 |
76 |
{ |
| |
77 |
77 |
if(!pszFile) |
| |
78 |
78 |
THROW(_T("Invalid argument"), 0, 0, 0); |
| |
79 |
79 |
|
| |
|
80 |
{ |
| |
|
81 |
boost::unique_lock<boost::shared_mutex> lock(GetImpl()->m_lock); |
| |
|
82 |
|
| |
|
83 |
|
| |
|
84 |
ClearNL(); |
| |
|
85 |
GetImpl()->m_strFilePath = pszFile; |
| |
|
86 |
} |
| |
|
87 |
|
| |
80 |
88 |
|
| |
81 |
89 |
boost::property_tree::wiptree tPropertyTree; |
| |
82 |
90 |
|
| |
83 |
91 |
std::wifstream ifs(pszFile, std::ios_base::in); |
| |
84 |
92 |
boost::property_tree::xml_parser::read_xml(ifs, tPropertyTree); |
| |
85 |
93 |
|
| |
86 |
94 |
boost::unique_lock<boost::shared_mutex> lock(GetImpl()->m_lock); |
| |
87 |
|
|
| |
88 |
|
|
| |
89 |
|
|
| |
90 |
|
ClearNL(); |
| |
91 |
|
GetImpl()->m_strFilePath = pszFile; |
| |
92 |
|
|
| |
93 |
95 |
GetImpl()->ImportFromPropertyTree(tPropertyTree, lock); |
| |
94 |
96 |
} |
| |
95 |
97 |
|
| |
96 |
98 |
void TConfig::Write() |
| |
97 |
99 |
{ |
| |
98 |
100 |
|
| |
99 |
101 |
boost::property_tree::wiptree tPropertyTree; |
| |
100 |
102 |
GetImpl()->ExportToPropertyTree(tPropertyTree); |
| |
101 |
103 |
|
| |
102 |
104 |
std::wofstream ofs(GetImpl()->m_strFilePath.c_str(), std::ios_base::out); |
| |
103 |
105 |
boost::property_tree::xml_parser::write_xml(ofs, tPropertyTree); |
| |
104 |
106 |
} |
| |
105 |
107 |
|
| |
106 |
108 |
void TConfig::ReadFromString(const TString& strInput) |
| |
107 |
109 |
{ |
| |
108 |
110 |
if(strInput.IsEmpty()) |
| |
109 |
111 |
THROW(_T("Invalid argument"), 0, 0, 0); |
| |
110 |
112 |
|
| |
111 |
113 |
boost::property_tree::wiptree tPropertyTree; |
| |
112 |
114 |
|