mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-23 05:27:47 +02:00
I18N - Record
- Localized Record object. - Remove copy ctor, operator= from Duration - unnecessary.
This commit is contained in:
parent
36d4ecab43
commit
db52cf7327
5 changed files with 23 additions and 32 deletions
|
@ -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
|
||||
|
|
|
@ -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 ()
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue