|
|
|
@ -24,38 +24,34 @@
|
|
|
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
|
{
|
|
|
|
|
/// \brief Access to ID field in records
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
struct IdAccessor
|
|
|
|
|
{
|
|
|
|
|
void setId(ESXRecordT& record, const ESM::RefId& id) const;
|
|
|
|
|
const ESM::RefId getId(const ESXRecordT& record) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void IdAccessor<ESXRecordT>::setId(ESXRecordT& record, const ESM::RefId& id) const
|
|
|
|
|
template <typename T>
|
|
|
|
|
void setRecordId(const decltype(T::mId)& id, T& record)
|
|
|
|
|
{
|
|
|
|
|
record.mId = id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
const ESM::RefId IdAccessor<ESXRecordT>::getId(const ESXRecordT& record) const
|
|
|
|
|
template <typename T>
|
|
|
|
|
auto getRecordId(const T& record)
|
|
|
|
|
{
|
|
|
|
|
return record.mId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
inline void IdAccessor<Land>::setId(Land& record, const ESM::RefId& id) const
|
|
|
|
|
inline void setRecordId(const ESM::RefId& id, Land& record)
|
|
|
|
|
{
|
|
|
|
|
int x = 0, y = 0;
|
|
|
|
|
int x = 0;
|
|
|
|
|
int y = 0;
|
|
|
|
|
|
|
|
|
|
Land::parseUniqueRecordId(id.getRefIdString(), x, y);
|
|
|
|
|
record.mX = x;
|
|
|
|
|
record.mY = y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
inline void IdAccessor<LandTexture>::setId(LandTexture& record, const ESM::RefId& id) const
|
|
|
|
|
inline ESM::RefId getRecordId(const Land& record)
|
|
|
|
|
{
|
|
|
|
|
return ESM::RefId::stringRefId(Land::createUniqueRecordId(record.mX, record.mY));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void setRecordId(LandTexture& record, const ESM::RefId& id)
|
|
|
|
|
{
|
|
|
|
|
int plugin = 0;
|
|
|
|
|
int index = 0;
|
|
|
|
@ -65,20 +61,13 @@ namespace CSMWorld
|
|
|
|
|
record.mIndex = index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
inline const ESM::RefId IdAccessor<Land>::getId(const Land& record) const
|
|
|
|
|
{
|
|
|
|
|
return ESM::RefId::stringRefId(Land::createUniqueRecordId(record.mX, record.mY));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
inline const ESM::RefId IdAccessor<LandTexture>::getId(const LandTexture& record) const
|
|
|
|
|
inline ESM::RefId getRecordId(const LandTexture& record)
|
|
|
|
|
{
|
|
|
|
|
return ESM::RefId::stringRefId(LandTexture::createUniqueRecordId(record.mPluginIndex, record.mIndex));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// \brief Single-type record collection
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT = IdAccessor<ESXRecordT>>
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
class Collection : public CollectionBase
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
@ -196,14 +185,14 @@ namespace CSMWorld
|
|
|
|
|
NestableColumn* getNestableColumn(int column) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
const std::vector<std::unique_ptr<Record<ESXRecordT>>>& Collection<ESXRecordT, IdAccessorT>::getRecords() const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
const std::vector<std::unique_ptr<Record<ESXRecordT>>>& Collection<ESXRecordT>::getRecords() const
|
|
|
|
|
{
|
|
|
|
|
return mRecords;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
bool Collection<ESXRecordT, IdAccessorT>::reorderRowsImp(int baseIndex, const std::vector<int>& newOrder)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
bool Collection<ESXRecordT>::reorderRowsImp(int baseIndex, const std::vector<int>& newOrder)
|
|
|
|
|
{
|
|
|
|
|
if (!newOrder.empty())
|
|
|
|
|
{
|
|
|
|
@ -236,14 +225,14 @@ namespace CSMWorld
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
int Collection<ESXRecordT, IdAccessorT>::cloneRecordImp(
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
int Collection<ESXRecordT>::cloneRecordImp(
|
|
|
|
|
const std::string& origin, const std::string& destination, UniversalId::Type type)
|
|
|
|
|
{
|
|
|
|
|
auto copy = std::make_unique<Record<ESXRecordT>>();
|
|
|
|
|
copy->mModified = getRecord(ESM::RefId::stringRefId(origin)).get();
|
|
|
|
|
copy->mState = RecordBase::State_ModifiedOnly;
|
|
|
|
|
IdAccessorT().setId(copy->get(), ESM::RefId::stringRefId(destination));
|
|
|
|
|
setRecordId(ESM::RefId::stringRefId(destination), copy->get());
|
|
|
|
|
|
|
|
|
|
if (type == UniversalId::Type_Reference)
|
|
|
|
|
{
|
|
|
|
@ -257,8 +246,8 @@ namespace CSMWorld
|
|
|
|
|
return index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
int Collection<ESXRecordT, IdAccessorT>::touchRecordImp(const std::string& id)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
int Collection<ESXRecordT>::touchRecordImp(const std::string& id)
|
|
|
|
|
{
|
|
|
|
|
int index = getIndex(ESM::RefId::stringRefId(id));
|
|
|
|
|
Record<ESXRecordT>& record = *mRecords.at(index);
|
|
|
|
@ -276,29 +265,29 @@ namespace CSMWorld
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::cloneRecord(
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void Collection<ESXRecordT>::cloneRecord(
|
|
|
|
|
const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type)
|
|
|
|
|
{
|
|
|
|
|
cloneRecordImp(origin.getRefIdString(), destination.getRefIdString(), type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
inline void Collection<Land, IdAccessor<Land>>::cloneRecord(
|
|
|
|
|
inline void Collection<Land>::cloneRecord(
|
|
|
|
|
const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type)
|
|
|
|
|
{
|
|
|
|
|
int index = cloneRecordImp(origin.getRefIdString(), destination.getRefIdString(), type);
|
|
|
|
|
mRecords.at(index)->get().setPlugin(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
bool Collection<ESXRecordT, IdAccessorT>::touchRecord(const ESM::RefId& id)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
bool Collection<ESXRecordT>::touchRecord(const ESM::RefId& id)
|
|
|
|
|
{
|
|
|
|
|
return touchRecordImp(id.getRefIdString()) != -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
inline bool Collection<Land, IdAccessor<Land>>::touchRecord(const ESM::RefId& id)
|
|
|
|
|
inline bool Collection<Land>::touchRecord(const ESM::RefId& id)
|
|
|
|
|
{
|
|
|
|
|
int index = touchRecordImp(id.getRefIdString());
|
|
|
|
|
if (index >= 0)
|
|
|
|
@ -310,22 +299,22 @@ namespace CSMWorld
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
Collection<ESXRecordT, IdAccessorT>::Collection()
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
Collection<ESXRecordT>::Collection()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
Collection<ESXRecordT, IdAccessorT>::~Collection()
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
Collection<ESXRecordT>::~Collection()
|
|
|
|
|
{
|
|
|
|
|
for (typename std::vector<Column<ESXRecordT>*>::iterator iter(mColumns.begin()); iter != mColumns.end(); ++iter)
|
|
|
|
|
delete *iter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::add(const ESXRecordT& record)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void Collection<ESXRecordT>::add(const ESXRecordT& record)
|
|
|
|
|
{
|
|
|
|
|
const ESM::RefId id = IdAccessorT().getId(record);
|
|
|
|
|
const ESM::RefId id = getRecordId(record);
|
|
|
|
|
|
|
|
|
|
auto iter = mIndex.find(id);
|
|
|
|
|
|
|
|
|
@ -343,20 +332,20 @@ namespace CSMWorld
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
int Collection<ESXRecordT, IdAccessorT>::getSize() const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
int Collection<ESXRecordT>::getSize() const
|
|
|
|
|
{
|
|
|
|
|
return mRecords.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
ESM::RefId Collection<ESXRecordT, IdAccessorT>::getId(int index) const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
ESM::RefId Collection<ESXRecordT>::getId(int index) const
|
|
|
|
|
{
|
|
|
|
|
return IdAccessorT().getId(mRecords.at(index)->get());
|
|
|
|
|
return getRecordId(mRecords.at(index)->get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
int Collection<ESXRecordT, IdAccessorT>::getIndex(const ESM::RefId& id) const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
int Collection<ESXRecordT>::getIndex(const ESM::RefId& id) const
|
|
|
|
|
{
|
|
|
|
|
int index = searchId(id);
|
|
|
|
|
|
|
|
|
@ -366,32 +355,32 @@ namespace CSMWorld
|
|
|
|
|
return index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
int Collection<ESXRecordT, IdAccessorT>::getColumns() const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
int Collection<ESXRecordT>::getColumns() const
|
|
|
|
|
{
|
|
|
|
|
return mColumns.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
QVariant Collection<ESXRecordT, IdAccessorT>::getData(int index, int column) const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
QVariant Collection<ESXRecordT>::getData(int index, int column) const
|
|
|
|
|
{
|
|
|
|
|
return mColumns.at(column)->get(*mRecords.at(index));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::setData(int index, int column, const QVariant& data)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void Collection<ESXRecordT>::setData(int index, int column, const QVariant& data)
|
|
|
|
|
{
|
|
|
|
|
return mColumns.at(column)->set(*mRecords.at(index), data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
const ColumnBase& Collection<ESXRecordT, IdAccessorT>::getColumn(int column) const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
const ColumnBase& Collection<ESXRecordT>::getColumn(int column) const
|
|
|
|
|
{
|
|
|
|
|
return *mColumns.at(column);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
NestableColumn* Collection<ESXRecordT, IdAccessorT>::getNestableColumn(int column) const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
NestableColumn* Collection<ESXRecordT>::getNestableColumn(int column) const
|
|
|
|
|
{
|
|
|
|
|
if (column < 0 || column >= static_cast<int>(mColumns.size()))
|
|
|
|
|
throw std::runtime_error("column index out of range");
|
|
|
|
@ -399,14 +388,14 @@ namespace CSMWorld
|
|
|
|
|
return mColumns.at(column);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::addColumn(Column<ESXRecordT>* column)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void Collection<ESXRecordT>::addColumn(Column<ESXRecordT>* column)
|
|
|
|
|
{
|
|
|
|
|
mColumns.push_back(column);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::merge()
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void Collection<ESXRecordT>::merge()
|
|
|
|
|
{
|
|
|
|
|
for (typename std::vector<std::unique_ptr<Record<ESXRecordT>>>::iterator iter(mRecords.begin());
|
|
|
|
|
iter != mRecords.end(); ++iter)
|
|
|
|
@ -415,8 +404,8 @@ namespace CSMWorld
|
|
|
|
|
purge();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::purge()
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void Collection<ESXRecordT>::purge()
|
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
@ -429,8 +418,8 @@ namespace CSMWorld
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::removeRows(int index, int count)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void Collection<ESXRecordT>::removeRows(int index, int count)
|
|
|
|
|
{
|
|
|
|
|
mRecords.erase(mRecords.begin() + index, mRecords.begin() + index + count);
|
|
|
|
|
|
|
|
|
@ -455,11 +444,11 @@ namespace CSMWorld
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::appendBlankRecord(const ESM::RefId& id, UniversalId::Type type)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void Collection<ESXRecordT>::appendBlankRecord(const ESM::RefId& id, UniversalId::Type type)
|
|
|
|
|
{
|
|
|
|
|
ESXRecordT record;
|
|
|
|
|
IdAccessorT().setId(record, id);
|
|
|
|
|
setRecordId(id, record);
|
|
|
|
|
record.blank();
|
|
|
|
|
|
|
|
|
|
auto record2 = std::make_unique<Record<ESXRecordT>>();
|
|
|
|
@ -469,8 +458,8 @@ namespace CSMWorld
|
|
|
|
|
insertRecord(std::move(record2), getAppendIndex(id, type), type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
int Collection<ESXRecordT, IdAccessorT>::searchId(const ESM::RefId& id) const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
int Collection<ESXRecordT>::searchId(const ESM::RefId& id) const
|
|
|
|
|
{
|
|
|
|
|
const auto iter = mIndex.find(id);
|
|
|
|
|
|
|
|
|
@ -480,63 +469,62 @@ namespace CSMWorld
|
|
|
|
|
return iter->second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::replace(int index, std::unique_ptr<RecordBase> record)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void Collection<ESXRecordT>::replace(int index, std::unique_ptr<RecordBase> record)
|
|
|
|
|
{
|
|
|
|
|
std::unique_ptr<Record<ESXRecordT>> tmp(static_cast<Record<ESXRecordT>*>(record.release()));
|
|
|
|
|
mRecords.at(index) = std::move(tmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::appendRecord(std::unique_ptr<RecordBase> record, UniversalId::Type type)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void Collection<ESXRecordT>::appendRecord(std::unique_ptr<RecordBase> record, UniversalId::Type type)
|
|
|
|
|
{
|
|
|
|
|
int index = getAppendIndex(IdAccessorT().getId(static_cast<Record<ESXRecordT>*>(record.get())->get()), type);
|
|
|
|
|
int index = getAppendIndex(getRecordId(static_cast<Record<ESXRecordT>*>(record.get())->get()), type);
|
|
|
|
|
insertRecord(std::move(record), index, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
int Collection<ESXRecordT, IdAccessorT>::getAppendIndex(const ESM::RefId& id, UniversalId::Type type) const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
int Collection<ESXRecordT>::getAppendIndex(const ESM::RefId& id, UniversalId::Type type) const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<int>(mRecords.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
std::vector<ESM::RefId> Collection<ESXRecordT, IdAccessorT>::getIds(bool listDeleted) const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
std::vector<ESM::RefId> Collection<ESXRecordT>::getIds(bool listDeleted) const
|
|
|
|
|
{
|
|
|
|
|
std::vector<ESM::RefId> ids;
|
|
|
|
|
|
|
|
|
|
for (auto iter = mIndex.begin(); iter != mIndex.end(); ++iter)
|
|
|
|
|
{
|
|
|
|
|
if (listDeleted || !mRecords[iter->second]->isDeleted())
|
|
|
|
|
ids.push_back(IdAccessorT().getId(mRecords[iter->second]->get()));
|
|
|
|
|
ids.push_back(getRecordId(mRecords[iter->second]->get()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
const Record<ESXRecordT>& Collection<ESXRecordT, IdAccessorT>::getRecord(const ESM::RefId& id) const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
const Record<ESXRecordT>& Collection<ESXRecordT>::getRecord(const ESM::RefId& id) const
|
|
|
|
|
{
|
|
|
|
|
int index = getIndex(id);
|
|
|
|
|
return *mRecords.at(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
const Record<ESXRecordT>& Collection<ESXRecordT, IdAccessorT>::getRecord(int index) const
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
const Record<ESXRecordT>& Collection<ESXRecordT>::getRecord(int index) const
|
|
|
|
|
{
|
|
|
|
|
return *mRecords.at(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::insertRecord(
|
|
|
|
|
std::unique_ptr<RecordBase> record, int index, UniversalId::Type type)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void Collection<ESXRecordT>::insertRecord(std::unique_ptr<RecordBase> record, int index, UniversalId::Type type)
|
|
|
|
|
{
|
|
|
|
|
int size = static_cast<int>(mRecords.size());
|
|
|
|
|
if (index < 0 || index > size)
|
|
|
|
|
throw std::runtime_error("index out of range");
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<Record<ESXRecordT>> record2(static_cast<Record<ESXRecordT>*>(record.release()));
|
|
|
|
|
ESM::RefId id = IdAccessorT().getId(record2->get());
|
|
|
|
|
ESM::RefId id = getRecordId(record2->get());
|
|
|
|
|
|
|
|
|
|
if (index == size)
|
|
|
|
|
mRecords.push_back(std::move(record2));
|
|
|
|
@ -555,17 +543,17 @@ namespace CSMWorld
|
|
|
|
|
mIndex.insert(std::make_pair(id, index));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
void Collection<ESXRecordT, IdAccessorT>::setRecord(int index, std::unique_ptr<Record<ESXRecordT>> record)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
void Collection<ESXRecordT>::setRecord(int index, std::unique_ptr<Record<ESXRecordT>> record)
|
|
|
|
|
{
|
|
|
|
|
if (IdAccessorT().getId(mRecords.at(index)->get()) != IdAccessorT().getId(record->get()))
|
|
|
|
|
if (getRecordId(mRecords.at(index)->get()) != getRecordId(record->get()))
|
|
|
|
|
throw std::runtime_error("attempt to change the ID of a record");
|
|
|
|
|
|
|
|
|
|
mRecords.at(index) = std::move(record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename ESXRecordT, typename IdAccessorT>
|
|
|
|
|
bool Collection<ESXRecordT, IdAccessorT>::reorderRows(int baseIndex, const std::vector<int>& newOrder)
|
|
|
|
|
template <typename ESXRecordT>
|
|
|
|
|
bool Collection<ESXRecordT>::reorderRows(int baseIndex, const std::vector<int>& newOrder)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|