added mandatory ID check stage
parent
72623652e4
commit
9fe7ff9690
@ -0,0 +1,21 @@
|
||||
|
||||
#include "mandatoryid.hpp"
|
||||
|
||||
#include "../world/idcollection.hpp"
|
||||
|
||||
CSMTools::MandatoryIdStage::MandatoryIdStage (const CSMWorld::IdCollectionBase& idCollection,
|
||||
const CSMWorld::UniversalId& collectionId, const std::vector<std::string>& ids)
|
||||
: mIdCollection (idCollection), mCollectionId (collectionId), mIds (ids)
|
||||
{}
|
||||
|
||||
int CSMTools::MandatoryIdStage::setup()
|
||||
{
|
||||
return mIds.size();
|
||||
}
|
||||
|
||||
void CSMTools::MandatoryIdStage::perform (int stage, std::vector<std::string>& messages)
|
||||
{
|
||||
if (mIdCollection.searchId (mIds.at (stage))==-1 ||
|
||||
mIdCollection.getRecord (mIds.at (stage)).isDeleted())
|
||||
messages.push_back (mCollectionId.toString() + " Missing mandatory record: " + mIds.at (stage));
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
#ifndef CSM_TOOLS_MANDATORYID_H
|
||||
#define CSM_TOOLS_MANDATORYID_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../world/universalid.hpp"
|
||||
|
||||
#include "stage.hpp"
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
class IdCollectionBase;
|
||||
}
|
||||
|
||||
namespace CSMTools
|
||||
{
|
||||
/// \brief Verify stage: make sure that records with specific IDs exist.
|
||||
class MandatoryIdStage : public Stage
|
||||
{
|
||||
const CSMWorld::IdCollectionBase& mIdCollection;
|
||||
CSMWorld::UniversalId mCollectionId;
|
||||
std::vector<std::string> mIds;
|
||||
|
||||
public:
|
||||
|
||||
MandatoryIdStage (const CSMWorld::IdCollectionBase& idCollection, const CSMWorld::UniversalId& collectionId,
|
||||
const std::vector<std::string>& ids);
|
||||
|
||||
virtual int setup();
|
||||
///< \return number of steps
|
||||
|
||||
virtual void perform (int stage, std::vector<std::string>& messages);
|
||||
///< Messages resulting from this tage will be appended to \a messages.
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue