I18N - Record

- Localized Record object.
- Remove copy ctor, operator= from Duration - unnecessary.
This commit is contained in:
Paul Beckingham
2009-06-06 22:06:02 -04:00
parent 36d4ecab43
commit db52cf7327
5 changed files with 23 additions and 32 deletions

View File

@@ -30,8 +30,12 @@
#include <stdlib.h>
#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 <std::string, Att> 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);
}
////////////////////////////////////////////////////////////////////////////////