7 #include "fwDataIO/reader/ArrayReader.hpp" 9 #include "fwDataIO/reader/registry/macros.hpp" 11 #include <fwCore/Exception.hpp> 13 #include <fwDataTools/helper/Array.hpp> 29 ::
fwData::location::enableSingleFile<
44 assert( ::fwData::location::SingleFile::dynamicCast(
m_location) );
45 ::boost::filesystem::path file = ::fwData::location::SingleFile::dynamicCast(
m_location)->getPath();
50 size_t arraySizeInBytes = array->resize(array->getSize());
51 char* buff = arrayHelper.
begin();
53 std::ifstream fs(file.string().c_str(), std::ios::in|std::ios::binary|std::ios::ate);
55 FW_RAISE_IF(
"Unable to read " << file, !fs.good());
57 std::streampos fileSize = fs.tellg();
58 fs.seekg(0, std::ios::beg);
60 FW_RAISE_IF(file <<
": Bad file size, expected: " << arraySizeInBytes <<
", was: " << fileSize,
61 arraySizeInBytes - fileSize != 0);
63 fs.read(buff, arraySizeInBytes);
FWDATAIO_API std::string extension() override
Defines extension supported by this reader ".raw".
FWDATAIO_API ArrayReader(::fwDataIO::reader::IObjectReader::Key key)
Constructor. Do nothing.
virtual FWDATAIO_API void read() override
Read the file with zlib API.
This namespace fwDataIO contains reader and writer for several framework's data.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Array Reader. Read file format .raw.
virtual std::shared_ptr< DataType > getConcreteObject()
m_object getter.
virtual FWDATAIO_API ~ArrayReader()
Destructor. Do nothing.
Base class for all object readers.
Contains the representation of the data objects used in the framework.
::fwData::location::ILocation::sptr m_location
Object location ( file path, directory path, url, etc )