diff --git a/i18n/strings.en-US b/i18n/strings.en-US index b511b7501..52e927eff 100644 --- a/i18n/strings.en-US +++ b/i18n/strings.en-US @@ -19,6 +19,9 @@ 106 ID Range too large 107 Not a sequence. 108 Interactive task is only available when built with ncurses support. +109 Empty record in input +110 Unrecognized characters at end of line +111 Record not recognized as format 4 # 2xx Commands 200 active diff --git a/src/Duration.cpp b/src/Duration.cpp index c9c1aee76..442fa1fef 100644 --- a/src/Duration.cpp +++ b/src/Duration.cpp @@ -37,31 +37,12 @@ Duration::Duration () { } -//////////////////////////////////////////////////////////////////////////////// -Duration::Duration (const Duration& other) -{ - throw std::string ("unimplemented Duration::Duration"); - mDays = other.mDays; -} - //////////////////////////////////////////////////////////////////////////////// Duration::Duration (const std::string& input) { parse (input); } -//////////////////////////////////////////////////////////////////////////////// -Duration& Duration::operator= (const Duration& other) -{ - throw std::string ("unimplemented Duration::operator="); - if (this != &other) - { - mDays = other.mDays; - } - - return *this; -} - //////////////////////////////////////////////////////////////////////////////// Duration::operator int () { diff --git a/src/Duration.h b/src/Duration.h index d5e1361dc..d804e318c 100644 --- a/src/Duration.h +++ b/src/Duration.h @@ -34,9 +34,7 @@ class Duration { public: Duration (); // Default constructor - Duration (const Duration&); // Copy constructor Duration (const std::string&); // Parse - Duration& operator= (const Duration&); // Assignment operator bool operator< (const Duration&); bool operator> (const Duration&); ~Duration (); // Destructor diff --git a/src/Record.cpp b/src/Record.cpp index 80be6488a..81f605253 100644 --- a/src/Record.cpp +++ b/src/Record.cpp @@ -30,8 +30,12 @@ #include #include "util.h" #include "Nibbler.h" +#include "Context.h" +#include "i18n.h" #include "Record.h" +extern Context context; + //////////////////////////////////////////////////////////////////////////////// Record::Record () { @@ -72,9 +76,9 @@ std::string Record::composeF4 () //////////////////////////////////////////////////////////////////////////////// // -// [ --> start --> name --> : --> " --> value --> " --> ] --> end -// ^ | -// +------------- \s <--------------+ +// start --> [ --> Att --> ] --> end +// ^ | +// +-------+ // void Record::parse (const std::string& input) { @@ -86,7 +90,8 @@ void Record::parse (const std::string& input) n.depleted ()) { if (line.length () == 0) - throw std::string ("Empty FF4 record"); + throw context.stringtable.get (RECORD_EMPTY, + "Empty record in input"); Nibbler nl (line); Att a; @@ -99,10 +104,12 @@ void Record::parse (const std::string& input) std::string remainder; nl.getUntilEOS (remainder); if (remainder.length ()) - throw std::string ("Unrecognized garbage at end of line"); + throw context.stringtable.get (RECORD_EXTRA, + "Unrecognized characters at end of line"); } else - throw std::string ("Record not recognized as FF4"); + throw context.stringtable.get (RECORD_NOT_FF4, + "Record not recognized as format 4"); } //////////////////////////////////////////////////////////////////////////////// @@ -151,11 +158,9 @@ void Record::set (const std::string& name, int value) //////////////////////////////////////////////////////////////////////////////// void Record::remove (const std::string& name) { - std::map copy = *this; - this->clear (); - foreach (i, copy) - if (i->first != name) - (*this)[i->first] = i->second; + Record::iterator it; + if ((it = this->find (name)) != this->end ()) + this->erase (it); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/i18n.h b/src/i18n.h index eebdcad13..95cae6d9f 100644 --- a/src/i18n.h +++ b/src/i18n.h @@ -42,6 +42,10 @@ #define INTERACTIVE_NO_NCURSES 108 +#define RECORD_EMPTY 109 +#define RECORD_EXTRA 110 +#define RECORD_NOT_FF4 111 + // 2xx Commands #define CMD_ACTIVE 200 #define CMD_ADD 201