-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quality 137/improve serialization deserialization (#142)
* general improvements to file sink and source * fix exceptions, improve file sink constructors * add auxiliary functions for binary read/write * replace {Read/Write}WithThrow in coord and cavity * replace Read/WriteWithThrow with bin_read/write in rbcalcgrid * replace Read/WriteWithThrow with bin_read/write in rbconvgrid * replace Read/WriteWithThrow with bin_read/write in base grid * update rbconvgrid with the specialized bin_read/write for strings * replace Read/WriteWithThrow with bin_read/write in fft grid * replace Read/WriteWithThrow with bin_read/write in pmf grid * add modifications to bin_read/write string specialization for retrocompatibility * replace Read/WriteWithThrow with bin_read/write in real grid * replace Read/WriteWithThrow with bin_read/write in vdw grid * replace Read/WriteWithThrow with bin_read/write in docking site * remove original read/write with throw * add diff test for cavity files * refactor out title validation * add test dependency for centos stream 9
- Loading branch information
1 parent
6f148a6
commit a570aa9
Showing
19 changed files
with
201 additions
and
279 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM quay.io/centos/centos:stream9 as base | ||
Check warning on line 1 in .github/docker/Dockerfile.centos-stream9 GitHub Actions / build (centos-stream9, g++) / buildThe 'as' keyword should match the case of the 'from' keyword
|
||
|
||
# Install dependencies | ||
RUN yum install -y popt-devel gcc-c++ make | ||
RUN yum install -y popt-devel gcc-c++ make diffutils |
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 |
---|---|---|
|
@@ -12,3 +12,4 @@ lib/libRbt.so | |
# test files | ||
*.as | ||
tests/results | ||
!tests/data/1YET_reference_out.as |
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
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,70 @@ | ||
|
||
#ifndef _RBT_BINARY_IO_H_ | ||
#define _RBT_BINARY_IO_H_ | ||
|
||
#include <iostream> | ||
|
||
#include "RbtError.h" | ||
#include "RbtFileError.h" | ||
|
||
namespace Rbt { | ||
|
||
template <typename T> | ||
inline void bin_write(std::ostream& ostr, const T& data) { | ||
try { | ||
ostr.write(reinterpret_cast<const char*>(&data), sizeof(T)); | ||
} catch (std::ios_base::failure& e) { | ||
throw RbtFileWriteError(_WHERE_, e.what()); | ||
} | ||
} | ||
|
||
template <typename T> | ||
inline void bin_write(std::ostream& ostr, const T* data, size_t n) { | ||
try { | ||
ostr.write(reinterpret_cast<const char*>(data), n * sizeof(T)); | ||
} catch (std::ios_base::failure& e) { | ||
throw RbtFileWriteError(_WHERE_, e.what()); | ||
} | ||
} | ||
|
||
template <typename T> | ||
inline void bin_read(std::istream& istr, T& data) { | ||
try { | ||
istr.read(reinterpret_cast<char*>(&data), sizeof(T)); | ||
} catch (std::ios_base::failure& e) { | ||
throw RbtFileReadError(_WHERE_, e.what()); | ||
} | ||
} | ||
|
||
template <typename T> | ||
inline void bin_read(std::istream& istr, T* data, size_t n) { | ||
try { | ||
istr.read(reinterpret_cast<char*>(data), n * sizeof(T)); | ||
|
||
} catch (std::ios_base::failure& e) { | ||
throw RbtFileReadError(_WHERE_, e.what()); | ||
} | ||
} | ||
|
||
template <> | ||
inline void bin_write(std::ostream& ostr, const std::string& data) { | ||
// casting size_t to int for retro-compatibility with old code only. | ||
// This is not the best way to do it and will be modified in the near future | ||
bin_write(ostr, (int)(data.size())); | ||
bin_write(ostr, data.data(), data.size()); | ||
} | ||
|
||
template <> | ||
inline void bin_read(std::istream& istr, std::string& data) { | ||
// similar to the bin_write(std::ostream& ostr, const std::string& data) function | ||
// this is a temporary solution for retro-compatibility with old code | ||
// the size_t is casted to int | ||
int size; | ||
bin_read(istr, size); | ||
data.resize(size); | ||
bin_read(istr, data.data(), size); | ||
} | ||
|
||
} // namespace Rbt | ||
|
||
#endif // _RBT_BINARY_IO_H_ |
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
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
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
Oops, something went wrong.