-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when saving output to file
- Loading branch information
Showing
4 changed files
with
73 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef VON_NEUMANN_FILE_PRINTER_HPP | ||
#define VON_NEUMANN_FILE_PRINTER_HPP | ||
|
||
#include "printer.hpp" | ||
|
||
#include <filesystem> | ||
#include <fstream> | ||
|
||
namespace vnm | ||
{ | ||
|
||
template <class T> | ||
class file_printer : public printer_interface | ||
{ | ||
public: | ||
file_printer( const std::filesystem::path& f, const vnm::machine& m ) | ||
: f_( f, std::ios::out | std::ios::trunc ), | ||
p_( std::make_unique<printer<T>>( f_, m ) ) | ||
{ | ||
} | ||
|
||
void print_registers_table() const override | ||
{ | ||
p_->print_registers_table(); | ||
} | ||
|
||
void print_registers() const override | ||
{ | ||
p_->print_registers(); | ||
} | ||
|
||
void print_memory() const override | ||
{ | ||
p_->print_memory(); | ||
} | ||
|
||
private: | ||
std::fstream f_; | ||
std::unique_ptr<printer_interface> p_; | ||
}; | ||
|
||
} // namespace vnm | ||
|
||
#endif // VON_NEUMANN_FILE_PRINTER_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
#include "with_sign.hpp" | ||
#include "word.hpp" | ||
|
||
#include <iomanip> | ||
|
||
namespace vnm | ||
{ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters