Fix for ReadMesh error reporting

This commit is contained in:
hultonha
2021-04-16 17:30:06 +01:00
parent 102a0e5dc8
commit f552fc7ccd
5 changed files with 38 additions and 20 deletions
@@ -729,15 +729,29 @@ namespace WhiteBox
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Serialization
//! The result of attempting to deserialize a white box mesh from a white box mesh stream.
enum class ReadResult
{
Full, //!< The white box mesh stream was full and was read into white box mesh (it is now initialized).
Empty, //!< The white box mesh stream was empty so no white box mesh was loaded.
Error //!< An error occurred while trying to deserialize white box mesh stream.
};
//! Take an input stream of bytes and create a white box mesh from the deserialized data.
//! @return Will return false if any error was encountered during deserialization, true otherwise.
//! @return Will return ReadResult::Full if the white box mesh stream was filled with data and
//! the white box mesh was initialized, ReadResult::Empty if white box mesh stream did not contain
//! any data (white box mesh will be left empty) or ReadResult::Error if any error was encountered
//! during deserialization.
//! @note A white box mesh must have been created first.
bool ReadMesh(WhiteBoxMesh& whiteBox, const WhiteBoxMeshStream& input);
ReadResult ReadMesh(WhiteBoxMesh& whiteBox, const WhiteBoxMeshStream& input);
//! Take an input stream and create a white box mesh from the deserialized data.
//! @return Will return false if any error was encountered during deserialization, true otherwise.
//! @return Will return ReadResult::Full if the white box mesh stream was filled with data and
//! the white box mesh was initialized, ReadResult::Empty if white box mesh stream did not contain
//! any data (white box mesh will be left empty) or ReadResult::Error if any error was encountered
//! during deserialization.
//! @note The input stream must not skip white space characters (std::noskipws must be set on the stream).
bool ReadMesh(WhiteBoxMesh& whiteBox, std::istream& input);
ReadResult ReadMesh(WhiteBoxMesh& whiteBox, std::istream& input);
//! Take a white box mesh and write it out to a stream of bytes.
//! @return Will return false if any error was encountered during serialization, true otherwise.