diff options
author | psychocrypt <psychocrypt@users.noreply.github.com> | 2017-10-01 00:36:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-01 00:36:33 +0200 |
commit | 4e5e98a095ed0ec038b9ea5421407b630bda273d (patch) | |
tree | 85c1401542a888b9d48255342095c8b6952d71bf /xmrstak/misc/configEditor.hpp | |
parent | 0afbc279e0db816dbb9d4d623929e2faf8108451 (diff) | |
parent | 2c8d64abfa1c989f260dd4fcaa5c6d7707a5f668 (diff) | |
download | xmr-stak-4e5e98a095ed0ec038b9ea5421407b630bda273d.zip xmr-stak-4e5e98a095ed0ec038b9ea5421407b630bda273d.tar.gz |
Merge pull request #1 from psychocrypt/topic-restructure11
refactor xmr-stak
Diffstat (limited to 'xmrstak/misc/configEditor.hpp')
-rw-r--r-- | xmrstak/misc/configEditor.hpp | 57 |
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..3960384 --- /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 |