5#include "sparta/functional/ArchData.hpp"
8namespace sparta::serialization::checkpoint::storage
18 std::stringstream ss_;
22 ss_.exceptions(std::ostream::eofbit | std::ostream::badbit |
23 std::ostream::failbit | std::ostream::goodbit);
26 void dump(std::ostream& o)
const {
29 for(; itr != s.end(); itr++){
34 strncpy((
char*)&ln_idx, s.substr(itr-s.begin(),
sizeof(ln_idx)).c_str(),
sizeof(ln_idx));
35 std::cout <<
"\nLine: " << ln_idx << std::endl;
38 for(uint16_t i=0; i<64; ++i){
41 o << std::setw(7) << std::hex << off;
46 o <<
' ' << std::setfill(
'0') << std::setw(2) << std::hex << (0xff & (uint16_t)chr);
58 uint32_t getSize()
const {
59 return ss_.str().size() +
sizeof(
decltype(*this));
62 void prepareForLoad() {
73 void writeLineBytes(
const char* data,
size_t size) {
74 ss_.write(data, size);
84 "Ostream error while writing checkpoint data");
103 "Encountered checkpoint data stream error or eof");
106 ss_.read((
char*)&ln_idx,
sizeof(ln_idx));
108 }
else if(ctrl ==
'E'){
112 << ctrl <<
"' control character was found where an 'L' or 'E' was found";
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
Exception class for all of Sparta.
static const line_idx_type INVALID_LINE_IDX
Invalid line index.
offset_type line_idx_type
Represents offsets into this ArchData.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Stringstream storage implementation.
void copyLineBytes(char *buf, uint32_t size)
Read bytes for the current line.
void endArchData()
Signals end of this checkpoint's data.
bool good() const
Is the reading state of this storage good? (i.e. haven't tried to read past the end of the data)
ArchData::line_idx_type getNextRestoreLine()
Restore next line. Return ArchData::INVALID_LINE_IDX on end of data.
std::enable_if< std::is_same< boost::mpl::int_< BO >, boost::mpl::int_< BE > >::value, T >::type reorder(const T &t)