summaryrefslogtreecommitdiffstats
path: root/xmrstak/misc/configEditor.hpp
diff options
context:
space:
mode:
authorpsychocrypt <psychocrypt@users.noreply.github.com>2017-09-29 20:32:31 +0200
committerpsychocrypt <psychocrypt@users.noreply.github.com>2017-09-30 23:46:08 +0200
commitcc429b68fadc502b981fd0acd64a5ff6e2ae1d15 (patch)
tree3fb23fc4db15dbdd08af4c7ea20134b9d82e58fd /xmrstak/misc/configEditor.hpp
parente5b0319d5a9f58762fa934ad700113908940cb31 (diff)
downloadxmr-stak-cc429b68fadc502b981fd0acd64a5ff6e2ae1d15.zip
xmr-stak-cc429b68fadc502b981fd0acd64a5ff6e2ae1d15.tar.gz
group files
- move source code to `src` - categorize files and move to group folder - change upper case class files to lower case - change C++ header to `*.hpp`
Diffstat (limited to 'xmrstak/misc/configEditor.hpp')
-rw-r--r--xmrstak/misc/configEditor.hpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/xmrstak/misc/configEditor.hpp b/xmrstak/misc/configEditor.hpp
new file mode 100644
index 0000000..80607ff
--- /dev/null
+++ b/xmrstak/misc/configEditor.hpp
@@ -0,0 +1,57 @@
+#pragma once
+
+#include <atomic>
+#include <string>
+#include <fstream>
+#include <streambuf>
+#include <regex>
+
+
+namespace xmrstak
+{
+
+struct ConfigEditor
+{
+ std::string m_fileContent;
+
+ ConfigEditor()
+ {
+
+ }
+
+ static bool file_exist( const std::string filename)
+ {
+ std::ifstream fstream(filename);
+ return fstream.good();
+ }
+
+ void set( const std::string && content)
+ {
+ m_fileContent = content;
+ }
+
+ bool load(const std::string filename)
+ {
+ std::ifstream fstream(filename);
+ m_fileContent = std::string(
+ (std::istreambuf_iterator<char>(fstream)),
+ std::istreambuf_iterator<char>()
+ );
+ return fstream.good();
+ }
+
+ void write(const std::string filename)
+ {
+ std::ofstream out(filename);
+ out << m_fileContent;
+ out.close();
+ }
+
+ void replace(const std::string search, const std::string substring)
+ {
+ m_fileContent = std::regex_replace(m_fileContent, std::regex(search), substring);
+ }
+
+};
+
+} // namepsace xmrstak
OpenPOWER on IntegriCloud