From 8e278873d4bd35a7cd7f3b6d9d7852fa422370b8 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 29 Dec 2008 12:09:27 -0500 Subject: Merged CHECK macro branch --- sigmod/CoinList.cpp | 108 ++++------------------------------------------------ 1 file changed, 8 insertions(+), 100 deletions(-) (limited to 'sigmod/CoinList.cpp') diff --git a/sigmod/CoinList.cpp b/sigmod/CoinList.cpp index d2b3e3a7..a8fd4f2f 100644 --- a/sigmod/CoinList.cpp +++ b/sigmod/CoinList.cpp @@ -102,107 +102,16 @@ QDomElement Sigmod::CoinList::save() const return xml; } -void Sigmod::CoinList::setName(const QString& name) -{ - CHECK(name); -} - -void Sigmod::CoinList::setScript(const Sigcore::Script& script) -{ - CHECK(script); -} - -QString Sigmod::CoinList::name() const -{ - return m_name; -} - -Sigcore::Script Sigmod::CoinList::script() const -{ - return m_script; -} - -const Sigmod::CoinListItem* Sigmod::CoinList::item(const int index) const -{ - if (index < itemCount()) - return m_items.at(index); - return NULL; -} - -Sigmod::CoinListItem* Sigmod::CoinList::item(const int index) -{ - if (index < itemCount()) - return m_items[index]; - return NULL; -} - -const Sigmod::CoinListItem* Sigmod::CoinList::itemById(const int id) const -{ - return item(itemIndex(id)); -} +SETTER(CoinList, QString&, Name, name) +SETTER(CoinList, Sigcore::Script&, Script, script) -Sigmod::CoinListItem* Sigmod::CoinList::itemById(const int id) -{ - return item(itemIndex(id)); -} +GETTER(CoinList, QString, name) +GETTER(CoinList, Sigcore::Script, script) -int Sigmod::CoinList::itemIndex(const int id) const -{ - for (int i = 0; i < itemCount(); ++i) - { - if (m_items[i]->id() == id) - return i; - } - return INT_MAX; -} +CHECK(CoinList, QString&, name) +CHECK(CoinList, Sigcore::Script&, script) -int Sigmod::CoinList::itemCount() const -{ - return m_items.size(); -} - -Sigmod::CoinListItem* Sigmod::CoinList::newItem() -{ - return newItem(new CoinListItem(this, itemId())); -} - -Sigmod::CoinListItem* Sigmod::CoinList::newItem(const QDomElement& xml) -{ - return newItem(new CoinListItem(xml, this, itemId())); -} - -Sigmod::CoinListItem* Sigmod::CoinList::newItem(const CoinListItem& item) -{ - return newItem(new CoinListItem(item, this, itemId())); -} - -Sigmod::CoinListItem* Sigmod::CoinList::newItem(CoinListItem* item) -{ - m_items.append(item); - return item; -} - -void Sigmod::CoinList::deleteItem(const int index) -{ - if (index < itemCount()) - { - delete m_items[index]; - m_items.removeAt(index); - } -} - -void Sigmod::CoinList::deleteItemById(const int id) -{ - deleteItem(itemIndex(id)); -} - -int Sigmod::CoinList::itemId() const -{ - int i = 0; - while ((i < itemCount()) && (itemIndex(i) != INT_MAX)) - ++i; - return i; -} +SUBCLASS(CoinList, Item, item, items) Sigmod::CoinList& Sigmod::CoinList::operator=(const CoinList& rhs) { @@ -217,6 +126,5 @@ Sigmod::CoinList& Sigmod::CoinList::operator=(const CoinList& rhs) void Sigmod::CoinList::clear() { - qDeleteAll(m_items); - m_items.clear(); + SUBCLASS_CLEAR(items); } -- cgit