diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-05-02 08:42:08 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-05-02 08:42:08 +0000 |
| commit | 822b5fcaa34b78b9668a58680f9e0d89aa3fd7bd (patch) | |
| tree | 40dc605213eff20f62b16e5f54e5e5e03d744d63 /pokemod/Store.cpp | |
| parent | 696414f1dc8bc419427efb6c1abe1bbae0a68a56 (diff) | |
[FIX] Exceptions no longer used in pokemod
[DEL] Exception and BugCatcher are no longer needed
[ADD] Object.cpp added
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@119 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Store.cpp')
| -rw-r--r-- | pokemod/Store.cpp | 58 |
1 files changed, 22 insertions, 36 deletions
diff --git a/pokemod/Store.cpp b/pokemod/Store.cpp index 27f33a6a..2ba5c553 100644 --- a/pokemod/Store.cpp +++ b/pokemod/Store.cpp @@ -45,46 +45,29 @@ Store::Store(const QDomElement& xml, const Object* parent, const int id) : load(xml, id); } -bool Store::validate() const +void Store::validate(QTextStream& stream) { - // TODO: validate -// bool valid = true; -// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Store \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg); -// if (m_name == "") -// { -// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is noe defiend"); -// valid = false; -// } -// if (!m_items.size()) -// { -// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no items"); -// valid = false; -// } -// QMap<int, bool> valueChecker; -// foreach (int item, m_items) -// { -// if (static_cast<const Pokemod*>(pokemod())->itemIndex(item) == INT_MAX) -// { -// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid item"); -// valid = false; -// } -// if (valueChecker[item]) -// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate of item %1").arg(item)); -// valueChecker[item] = true; -// } -// return valid; + TEST_SETUP(); + if (m_name.isEmpty()) + error(stream, "Name is empty"); + if (m_item.size()) + { + TEST_LIST(setItem, item); + } + else + error(stream, "No items in the store"); } void Store::load(const QDomElement& xml, int id) { LOAD_ID(); - LOAD_LIST(int, items); + LOAD_LIST(int, item); } QDomElement Store::save() const { SAVE_CREATE(); - SAVE_LIST(int, items); + SAVE_LIST(int, item); return xml; } @@ -93,17 +76,20 @@ void Store::setName(const QString& name) m_name = name; } -void Store::setItem(const int item, const bool state) throw(BoundsException) +void Store::setItem(const int item, const bool state) { if (static_cast<const Pokemod*>(pokemod())->itemIndex(item) == INT_MAX) - error<BoundsException>("item"); + { + boundsError("item"); + return; + } if (state) { - if (!m_items.contains(item)) - m_items.append(item); + if (!m_item.contains(item)) + m_item.append(item); } else - m_items.removeAll(item); + m_item.removeAll(item); } QString Store::name() const @@ -113,7 +99,7 @@ QString Store::name() const bool Store::item(const int item) const { - return m_items.contains(item); + return m_item.contains(item); } Store& Store::operator=(const Store& rhs) @@ -121,6 +107,6 @@ Store& Store::operator=(const Store& rhs) if (this == &rhs) return *this; COPY(name); - COPY(items); + COPY(item); return *this; } |
