Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature exception2 #152

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions corelib/src/libs/SireBase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ set ( SIREBASE_SOURCES
savestate.cpp
sharedpolypointer.cpp
slice.cpp
sparsematrix.cpp
stringmangler.cpp
stringproperty.cpp
tempdir.cpp
Expand Down
69 changes: 69 additions & 0 deletions corelib/src/libs/SireBase/sparsematrix.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/********************************************\
*
* Sire - Molecular Simulation Framework
*
* Copyright (C) 2024 Christopher Woods
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* For full details of the license please see the COPYING file
* that should have come with this distribution.
*
* You can contact the authors via the website
* at https://sire.openbiosim.org
*
\*********************************************/

#include "sparsematrix.hpp"

#include "sireglobal.h"

using namespace SireBase;
using namespace SireStream;

static const auto sparse_magic = Sire::getMagic("SireBase::SparseMatrix");

namespace SireBase
{
namespace detail
{
void writeSparseMatrixMagic(QDataStream &ds, VersionID v)
{
SireStream::writeHeader(ds, sparse_magic, v);
}

VersionID checkSparseMatrixMagic(QDataStream &ds)
{
try
{
return SireStream::readHeader(ds, sparse_magic, "SireBase::SparseMatrix");
}
catch (const SireStream::magic_error &)
{
// have to assume this is an old-style sparse matrix
return 1;
}
}

void throwSparseMatrixMagicError(VersionID v, const QString &supported)
{
throw SireStream::version_error(
QObject::tr("Invalid version for SparseMatrix - got %1 but only version(s) %2 are supported")
.arg(v)
.arg(supported),
CODELOC);
}
}
}
Loading
Loading