diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-03-31 01:17:59 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-03-31 01:17:59 +0000 |
| commit | 9a65bc6bb7c8da1dfa5b101579e52845c75848ef (patch) | |
| tree | 258900f882a6998ac6fa525bd247e302028a8911 /pokemod/Author.cpp | |
| parent | 8e1ec2aec50999bae30625303f2c96e5b3b7f318 (diff) | |
| download | sigen-9a65bc6bb7c8da1dfa5b101579e52845c75848ef.tar.gz sigen-9a65bc6bb7c8da1dfa5b101579e52845c75848ef.tar.xz sigen-9a65bc6bb7c8da1dfa5b101579e52845c75848ef.zip | |
[FIX] Member variables now use m_ prefix
[FIX] Lots of minor fixes
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@95 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Author.cpp')
| -rw-r--r-- | pokemod/Author.cpp | 136 |
1 files changed, 67 insertions, 69 deletions
diff --git a/pokemod/Author.cpp b/pokemod/Author.cpp index a701e535..7f170cef 100644 --- a/pokemod/Author.cpp +++ b/pokemod/Author.cpp @@ -1,132 +1,130 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pokemod/Author.cpp -// Purpose: Define an author of a PokéMod -// Author: Ben Boeckel -// Modified by: Ben Boeckel -// Created: Wed Feb 28 20:42:17 2007 -// Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions -// Licence: -// 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, see <http://www.gnu.org/licenses/>. -///////////////////////////////////////////////////////////////////////////// +/* + * Copyright 2007-2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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, see <http://www.gnu.org/licenses/>. + */ +// Qt includes #include <QRegExp> +// Pokemod includes #include "Pokemod.h" + +// Header include #include "Author.h" -Author::Author(const Pokemod* par, const int _id) : - Object("Author", par, _id), - name(""), - email(""), - role("") +Author::Author(const Pokemod* pokemod, const int id) : + Object("Author", pokemod, id), + m_name(""), + m_email(""), + m_role("") { } -Author::Author(const Pokemod* par, const Author& a, const int _id) : - Object("Author", par, _id) +Author::Author(const Pokemod* pokemod, const Author& author, const int id) : + Object("Author", pokemod, id) { - *this = a; + *this = author; } -Author::Author(const Pokemod* par, const QString& fname, const int _id) : - Object("Author", par, _id) +Author::Author(const Pokemod* pokemod, const QString& fileName, const int id) : + Object("Author", pokemod, id) { - load(fname, _id); + load(fileName, id); } bool Author::validate() const { bool valid = true; - pokemod->validationMsg(QString("---Author \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); - if (name == "") + pokemod()->validationMsg(QString("---Author \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg); + if (m_name == "") { - pokemod->validationMsg("Name not defined"); + pokemod()->validationMsg("Name not defined"); valid = false; } - if (email == "") - pokemod->validationMsg("Email not defined", Pokemod::V_Warn); - else if (!QRegExp("[a-zA-Z0-9%-_\\.]+@[a-zA-Z0-9\\-]+(\\.[a-zA-Z]+)*\\.[a-zA-Z]{2,4}").exactMatch(email)) + if (m_email == "") + pokemod()->validationMsg("Email not defined", Pokemod::V_Warn); + else if (!QRegExp("[a-zA-Z0-9%-_\\.]+@[a-zA-Z0-9\\-]+(\\.[a-zA-Z]+)*\\.[a-zA-Z]{2,4}").exactMatch(m_email)) { - pokemod->validationMsg("Invalid email"); + pokemod()->validationMsg("Invalid email"); valid = false; } - if (role == "") + if (m_role == "") { - pokemod->validationMsg("Role not defined"); + pokemod()->validationMsg("Role not defined"); valid = false; } return valid; } -void Author::load(const QString& fname, const int _id) throw(Exception) +void Author::load(const QString& fileName, int id) throw(Exception) { - Ini ini(fname); - if (_id == -1) + Ini ini(fileName); + if (id == INT_MAX) ini.getValue("id", id); - else - id = _id; - ini.getValue("name", name); - ini.getValue("email", email); - ini.getValue("role", role); + setId(id); + ini.getValue("name", m_name); + ini.getValue("email", m_email); + ini.getValue("role", m_role); } void Author::save() const throw(Exception) { Ini ini; - ini.addField("id", id); - ini.addField("name", name); - ini.addField("email", email); - ini.addField("role", role); - ini.save(QString("%1/author/%2.pini").arg(pokemod->getPath()).arg(name)); + ini.addField("id", id()); + ini.addField("name", m_name); + ini.addField("email", m_email); + ini.addField("role", m_role); + ini.save(QString("%1/author/%2.pini").arg(pokemod()->path()).arg(m_name)); } -void Author::setName(const QString& n) +void Author::setName(const QString& name) { - name = n; + m_name = name; } -void Author::setEmail(const QString& e) +void Author::setEmail(const QString& email) { - email = e; + m_email = email; } -void Author::setRole(const QString& r) +void Author::setRole(const QString& role) { - role = r; + m_role = role; } -QString Author::getName() const +QString Author::name() const { - return name; + return m_name; } -QString Author::getEmail() const +QString Author::email() const { - return email; + return m_email; } -QString Author::getRole() const +QString Author::role() const { - return role; + return m_role; } Author& Author::operator=(const Author& rhs) { if (this == &rhs) return *this; - name = rhs.name; - email = rhs.email; - role = rhs.role; + m_name = rhs.m_name; + m_email = rhs.m_email; + m_role = rhs.m_role; return *this; } |
