diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:03:20 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:03:20 +0200 |
commit | 528635604eea1d8c679a3d038e2f00030ef72444 (patch) | |
tree | 9c3cbec29aa7d3e209939662e040b9342c9e7400 /shared/serialize.cpp | |
parent | 3.1 (diff) | |
download | FreeFileSync-528635604eea1d8c679a3d038e2f00030ef72444.tar.gz FreeFileSync-528635604eea1d8c679a3d038e2f00030ef72444.tar.bz2 FreeFileSync-528635604eea1d8c679a3d038e2f00030ef72444.zip |
3.2
Diffstat (limited to 'shared/serialize.cpp')
-rw-r--r-- | shared/serialize.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/shared/serialize.cpp b/shared/serialize.cpp new file mode 100644 index 00000000..616d244d --- /dev/null +++ b/shared/serialize.cpp @@ -0,0 +1,50 @@ +#include "serialize.h" +#include <wx/intl.h> + +using namespace Utility; + + +void ReadInputStream::throwReadError() //throw FileError() +{ + throw FreeFileSync::FileError(wxString(_("Error reading from synchronization database:")) + wxT(" \n") + + wxT("\"") + errorObjName_ + wxT("\"")); +} + + +ReadInputStream::CharArray ReadInputStream::readArrayC() +{ + CharArray buffer(new std::vector<char>); + const size_t byteCount = readNumberC<size_t>(); + if (byteCount > 0) + { + buffer->resize(byteCount); + stream_.Read(&(*buffer)[0], byteCount); + check(); + if (stream_.LastRead() != byteCount) //some additional check + throwReadError(); + } + return buffer; +} + + +//-------------------------------------------------------------------------------------------------------- +void WriteOutputStream::throwWriteError() //throw FileError() +{ + throw FreeFileSync::FileError(wxString(_("Error writing to synchronization database:")) + wxT(" \n") + + wxT("\"") + errorObjName_ + wxT("\"")); +} + + +void WriteOutputStream::writeArrayC(const std::vector<char>& buffer) +{ + writeNumberC<size_t>(buffer.size()); + if (buffer.size() > 0) + { + stream_.Write(&buffer[0], buffer.size()); + check(); + if (stream_.LastWrite() != buffer.size()) //some additional check + throwWriteError(); + } +} + + |