From 3595239f08f2bc1df32ef22ed6de9bde10ca3384 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 4 Jun 2007 01:35:20 +0000 Subject: Style cleanup, minor Matrix fixes, duplication validations, Pokemod methods git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@19 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/Author.cpp | 314 ++++++++++++++++++++++++++--------------------------- 1 file changed, 157 insertions(+), 157 deletions(-) (limited to 'pokemod/Author.cpp') diff --git a/pokemod/Author.cpp b/pokemod/Author.cpp index fadd0893..20d34db3 100644 --- a/pokemod/Author.cpp +++ b/pokemod/Author.cpp @@ -24,9 +24,9 @@ #include "Author.h" PokeGen::PokeMod::Author::Author(const unsigned _id) : - name(""), - email(""), - role("") + name(""), + email(""), + role("") { LogCtor("Author", id); id = _id; @@ -96,158 +96,158 @@ void PokeGen::PokeMod::Author::Validate(const wxListBox &output) LogValNotSet("Author", "role", id, name); output.Append(ConsoleLogValNotSet("Author", "role", id, name))); isValid = false; - } - LogValidateOver("Author", isValid, id, name); -} + } + LogValidateOver("Author", isValid, id, name); + } #endif - -void PokeGen::PokeMod::Author::ImportIni(Ini &ini, const unsigned _id) -{ - LogImportStart("Author"); - String curName; - if (_id == UINT_MAX) - { - ini.GetValue("id", id); - if (id == UINT_MAX) - LogIdNotFound("Author"); - } - else - id = _id; - ini.GetValue("name", name); - ini.GetValue("email", email); - ini.GetValue("role", role); - LogImportOver("Author", id, name); -} - -void PokeGen::PokeMod::Author::ExportIni(std::ofstream &fout) const -{ - LogExportStart("Author", id, name); - // Declare the elements - Ini exAuthor("author"); - exAuthor.AddField("id", id); - exAuthor.AddField("name", name); - exAuthor.AddField("email", email); - exAuthor.AddField("role", role); - exAuthor.Export(fout); - LogExportOver("Author", id, name); -} - -void PokeGen::PokeMod::Author::SetName(const String &n) -{ - LogSetVar("Author", id, "name", n, name); - name = n; -} - -void PokeGen::PokeMod::Author::SetEmail(const String &e) -{ - LogSetVar("Author", id, "email", e, name); - email = e; -} - -void PokeGen::PokeMod::Author::SetRole(const String &r) -{ - LogSetVar("Author", id, "role", r, name); - role = r; -} - -PokeGen::PokeMod::String PokeGen::PokeMod::Author::GetName() const -{ - LogFetchVar("Author", id, "name", name); - return name; -} - -PokeGen::PokeMod::String PokeGen::PokeMod::Author::GetEmail() const -{ - LogFetchVar("Author", id, "email", email, name); - return email; -} - -PokeGen::PokeMod::String PokeGen::PokeMod::Author::GetRole() const -{ - LogFetchVar("Author", id, "role", role, name); - return role; -} - -bool PokeGen::PokeMod::Author::IsValidEmail() const -{ - bool valid = true; - Log(String("Author: Validating email of %d (%s)", id, name.c_str()), PM_DEBUG_DEBUG); - EmailCheck stage = EM_NAME; - int count = 0; - for (unsigned i = 0; (i < email.length()) && valid; ++i) - { - switch (stage) - { - case EM_NAME: - switch (email[i]) - { - // Only allow alphanumerics and '%-_.' in the name - case 'a' ... 'z': - case 'A' ... 'Z': - case '0' ... '9': - case '%': - case '-': - case '_': - case '.': - ++count; - break; - // Move to the next part if '@' is encountered - case '@': - if (!count) - valid = false; - count = 0; - stage = EM_HOST; - break; - // Not valid if anything else is encountered - default: - valid = false; - } - break; - case EM_HOST: - switch (email[i]) - { - // Only allow alphanumerics and '%-_.' in the host - case 'a' ... 'z': - case 'A' ... 'Z': - case '0' ... '9': - case '-': - ++count; - break; - // Move to the next part if '.' is encountered - case '.': - if (!count) - valid = false; - count = 0; - stage = EM_DOMAIN; - break; - // Not valid if anything else is encountered - default: - valid = false; - } - break; - case EM_DOMAIN: - switch (email[i]) - { - // Only allow alphanumerics and '%-_.' in the host - case 'a' ... 'z': - case 'A' ... 'Z': - ++count; - break; - // Move to the next domain extension if '.' is encountered - case '.': - if (!count) - valid = false; - count = 0; - break; - // Not valid if anything else is encountered - default: - valid = false; - } - } - } - // Make sure the domain was entered and the extension is in the valid range - if ((stage != EM_DOMAIN) || (count < 2) || (4 < count)) - valid = false; - Log(String("Author: Validated email of %d (%s) as %s", id, name.c_str(), valid ? "valid" : "invalid"), PM_DEBUG_DEBUG); - return valid; -} + + void PokeGen::PokeMod::Author::ImportIni(Ini &ini, const unsigned _id) + { + LogImportStart("Author"); + String curName; + if (_id == UINT_MAX) + { + ini.GetValue("id", id); + if (id == UINT_MAX) + LogIdNotFound("Author"); + } + else + id = _id; + ini.GetValue("name", name); + ini.GetValue("email", email); + ini.GetValue("role", role); + LogImportOver("Author", id, name); + } + + void PokeGen::PokeMod::Author::ExportIni(std::ofstream &fout) const + { + LogExportStart("Author", id, name); + Ini exAuthor("author"); + exAuthor.AddField("id", id); + exAuthor.AddField("name", name); + exAuthor.AddField("email", email); + exAuthor.AddField("role", role); + exAuthor.Export(fout); + LogExportOver("Author", id, name); + } + + void PokeGen::PokeMod::Author::SetName(const String &n) + { + LogSetVar("Author", id, "name", n, name); + name = n; + } + + void PokeGen::PokeMod::Author::SetEmail(const String &e) + { + LogSetVar("Author", id, "email", e, name); + email = e; + } + + void PokeGen::PokeMod::Author::SetRole(const String &r) + { + LogSetVar("Author", id, "role", r, name); + role = r; + } + + PokeGen::PokeMod::String PokeGen::PokeMod::Author::GetName() const + { + LogFetchVar("Author", id, "name", name); + return name; + } + + PokeGen::PokeMod::String PokeGen::PokeMod::Author::GetEmail() const + { + LogFetchVar("Author", id, "email", email, name); + return email; + } + + PokeGen::PokeMod::String PokeGen::PokeMod::Author::GetRole() const + { + LogFetchVar("Author", id, "role", role, name); + return role; + } + + bool PokeGen::PokeMod::Author::IsValidEmail() const + { + bool valid = true; + Log(String("Author: Validating email of %d (%s)", id, name.c_str()), PM_DEBUG_DEBUG); + EmailCheck stage = EM_NAME; + int count = 0; + for (unsigned i = 0; (i < email.length()) && valid; ++i) + { + switch (stage) + { + case EM_NAME: + switch (email[i]) + { + // Only allow alphanumerics and '%-_.' in the name + case 'a' ... 'z': + case 'A' ... 'Z': + case '0' ... '9': + case '%': + case '-': + case '_': + case '.': + ++count; + break; + // Move to the next part if '@' is encountered + case '@': + if (!count) + valid = false; + count = 0; + stage = EM_HOST; + break; + // Not valid if anything else is encountered + default: + valid = false; + } + break; + case EM_HOST: + switch (email[i]) + { + // Only allow alphanumerics and '%-_.' in the host + case 'a' ... 'z': + case 'A' ... 'Z': + case '0' ... '9': + case '-': + ++count; + break; + // Move to the next part if '.' is encountered + case '.': + if (!count) + valid = false; + count = 0; + stage = EM_DOMAIN; + break; + // Not valid if anything else is encountered + default: + valid = false; + } + break; + case EM_DOMAIN: + switch (email[i]) + { + // Only allow alphanumerics and '%-_.' in the host + case 'a' ... 'z': + case 'A' ... 'Z': + ++count; + break; + // Move to the next domain extension if '.' is encountered + case '.': + if (!count) + valid = false; + count = 0; + break; + // Not valid if anything else is encountered + default: + valid = false; + } + } + } + // Make sure the domain was entered and the extension is in the valid range + if ((stage != EM_DOMAIN) || (count < 2) || (4 < count)) + valid = false; + Log(String("Author: Validated email of %d (%s) as %s", id, name.c_str(), valid ? "valid" : "invalid"), PM_DEBUG_DEBUG); + return valid; + } + -- cgit