9 #ifndef __stir_IO_FileSignature_h__ 10 #define __stir_IO_FileSignature_h__ 41 explicit FileSignature(std::istream& input) { this->_read_signature(input); }
47 this->_read_signature(input);
55 std::size_t
size()
const {
return this->_size; }
58 static const std::size_t _max_signature_size = 1024U;
59 char _signature[_max_signature_size];
62 void _read_signature(std::istream& input)
65 std::fill(this->_signature, this->_signature + this->_max_signature_size,
'\0');
66 input.read(this->_signature, this->_max_signature_size);
67 this->_signature[this->_max_signature_size - 1] =
'\0';
68 this->_size =
static_cast<std::size_t
>(input.gcount());
A class to read/store the file signature.
Definition: FileSignature.h:34
This file declares various utility functions.
FILE *& open_read_binary(FILE *&fptr, const string &name)
opens a FILE for reading binary data. Calls error() when it does not succeed.
Definition: utilities.cxx:79
const char * get_signature() const
get access to the signature
Definition: FileSignature.h:52
FileSignature(const std::string &filename)
open file and read signature
Definition: FileSignature.h:43
std::size_t size() const
return size of valid signature read from the file
Definition: FileSignature.h:55
FileSignature(std::istream &input)
read signature
Definition: FileSignature.h:41