Skip to content
Snippets Groups Projects
Commit f2e650c5 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

builtin commands for read and write file

parent f9de4179
No related branches found
No related tags found
No related merge requests found
Pipeline #
/*
* ReadFile.cpp
*
* Created on: 21. 8. 2017
* Author: Jan Travnicek
*/
#include "ReadFile.h"
#include <registration/AlgoRegistration.hpp>
#include <fstream>
#include <streambuf>
namespace cli {
namespace builtin {
std::string ReadFile::read ( const std::string & data ) {
std::ifstream t ( data );
return std::string ( ( std::istreambuf_iterator < char > ( t ) ), std::istreambuf_iterator < char > ( ) );
}
auto ReadFileString = registration::AbstractRegister < ReadFile, std::string, const std::string & > ( ReadFile::read );
} /* namespace builtin */
} /* namespace cli */
/*
* ReadFile.h
*
* Created on: 16. 8. 2017
* Author: Jan Travnicek
*/
#ifndef _READ_FILE_H_
#define _READ_FILE_H_
#include <string>
namespace cli {
namespace builtin {
class ReadFile {
public:
static std::string read ( const std::string & filename );
};
} /* namespace builtin */
} /* namespace cli */
#endif /* _READ_FILE_H_ */
/*
* WriteFile.cpp
*
* Created on: 21. 8. 2017
* Author: Jan Travnicek
*/
#include "WriteFile.h"
#include <registration/AlgoRegistration.hpp>
#include <fstream>
namespace cli {
namespace builtin {
void WriteFile::write ( const std::string & filename, const std::string & data ) {
std::ofstream ( filename ) << data;
}
auto WriteFileString = registration::AbstractRegister < WriteFile, void, const std::string &, const std::string & > ( WriteFile::write );
} /* namespace builtin */
} /* namespace cli */
/*
* WriteFile.h
*
* Created on: 16. 8. 2017
* Author: Jan Travnicek
*/
#ifndef _WRITE_FILE_H_
#define _WRITE_FILE_H_
#include <string>
namespace cli {
namespace builtin {
class WriteFile {
public:
static void write ( const std::string & filename, const std::string & data );
};
} /* namespace builtin */
} /* namespace cli */
#endif /* _WRITE_FILE_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment