Commit c5676f1d by Maarten L. Hekkelman

accept compressed raw data in mmcif::File constructor

parent 86854581
...@@ -61,8 +61,8 @@ AC_SUBST(LIBTOOL_DEPS) ...@@ -61,8 +61,8 @@ AC_SUBST(LIBTOOL_DEPS)
dnl versioning, first for libtool dnl versioning, first for libtool
LIBCIF_CURRENT=1 LIBCIF_CURRENT=1
LIBCIF_REVISION=0 LIBCIF_REVISION=1
LIBCIF_AGE=0 LIBCIF_AGE=1
LIBCIF_LT_CURRENT="${LIBCIF_CURRENT}" LIBCIF_LT_CURRENT="${LIBCIF_CURRENT}"
LIBCIF_LT_VERSION="${LIBCIF_CURRENT}:${LIBCIF_REVISION}:${LIBCIF_AGE}" LIBCIF_LT_VERSION="${LIBCIF_CURRENT}:${LIBCIF_REVISION}:${LIBCIF_AGE}"
...@@ -71,7 +71,7 @@ AC_SUBST(LIBCIF_LT_CURRENT) ...@@ -71,7 +71,7 @@ AC_SUBST(LIBCIF_LT_CURRENT)
AC_SUBST(LIBCIF_LT_VERSION) AC_SUBST(LIBCIF_LT_VERSION)
dnl and now for the semantic version dnl and now for the semantic version
LIBCIF_SEMANTIC_VERSION=1.0.0 LIBCIF_SEMANTIC_VERSION=1.1.0
AC_SUBST(LIBCIF_SEMANTIC_VERSION) AC_SUBST(LIBCIF_SEMANTIC_VERSION)
AC_ARG_VAR([DEBUG], [Build a debug version of the library]) AC_ARG_VAR([DEBUG], [Build a debug version of the library])
......
...@@ -68,6 +68,9 @@ struct FileImpl ...@@ -68,6 +68,9 @@ struct FileImpl
void FileImpl::load_data(const char* data, size_t length) void FileImpl::load_data(const char* data, size_t length)
{ {
bool gzipped = length > 2 and data[0] == (char)0x1f and data[1] == (char)0x8b;
bool bzip2ed = length > 3 and data[0] == (char)0x42 and data[1] == (char)0x5A and data[2] == (char)0x68;
try try
{ {
// First try mmCIF // First try mmCIF
...@@ -77,7 +80,15 @@ void FileImpl::load_data(const char* data, size_t length) ...@@ -77,7 +80,15 @@ void FileImpl::load_data(const char* data, size_t length)
} buffer(const_cast<char*>(data), length); } buffer(const_cast<char*>(data), length);
std::istream is(&buffer); std::istream is(&buffer);
mData.load(is);
io::filtering_stream<io::input> in;
if (gzipped)
in.push(io::gzip_decompressor());
else if (bzip2ed)
in.push(io::bzip2_decompressor());
in.push(is);
mData.load(in);
} }
catch (const cif::CifParserError& e) catch (const cif::CifParserError& e)
{ {
...@@ -89,7 +100,14 @@ void FileImpl::load_data(const char* data, size_t length) ...@@ -89,7 +100,14 @@ void FileImpl::load_data(const char* data, size_t length)
std::istream is(&buffer); std::istream is(&buffer);
ReadPDBFile(is, mData); io::filtering_stream<io::input> in;
if (gzipped)
in.push(io::gzip_decompressor());
else if (bzip2ed)
in.push(io::bzip2_decompressor());
in.push(is);
ReadPDBFile(in, mData);
} }
// Yes, we've parsed the data. Now locate the datablock. // Yes, we've parsed the data. Now locate the datablock.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment