MCPcopy Create free account
hub / github.com/davisking/dlib / deserialize_floating_point

Function deserialize_floating_point

dlib/serialize.h:721–750  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

719
720 template <typename T>
721 inline void deserialize_floating_point (
722 T& item,
723 std::istream& in
724 )
725 {
726 // check if the serialized data uses the older ASCII based format. We can check
727 // this easily because the new format starts with the integer control byte which
728 // always has 0 bits in the positions corresponding to the bitmask 0x70. Moreover,
729 // since the previous format used ASCII numbers we know that no valid bytes can
730 // have bit values of one in the positions indicated 0x70. So this test looks at
731 // the first byte and checks if the serialized data uses the old format or the new
732 // format.
733 if ((in.rdbuf()->sgetc()&0x70) == 0)
734 {
735 try
736 {
737 // Use the fast and compact binary serialization format.
738 float_details temp;
739 deserialize(temp, in);
740 item = temp;
741 }
742 catch (serialization_error& e)
743 { throw serialization_error(e.info + "\n while deserializing a floating point number."); }
744 }
745 else
746 {
747 if (old_deserialize_floating_point(item, in))
748 throw serialization_error("Error deserializing a floating point number.");
749 }
750 }
751
752 inline void serialize ( const float& item, std::ostream& out)
753 {

Callers 1

deserializeFunction · 0.85

Calls 3

serialization_errorClass · 0.85
deserializeFunction · 0.70

Tested by

no test coverage detected