C++11: Took advantage of N1757.

This commit is contained in:
Paul Beckingham 2015-04-06 15:30:39 -04:00
parent afec6d451f
commit 935b2993f3
11 changed files with 81 additions and 81 deletions

View file

@ -726,7 +726,7 @@ void CLI::addArg (const std::string& arg, Lexer::Type type /* = Lexer::Type::wor
Lexer lex (raw);
lex.ambiguity (false);
std::vector <std::pair <std::string, Lexer::Type> > lexemes;
std::vector <std::pair <std::string, Lexer::Type>> lexemes;
while (lex.token (lexeme, type))
lexemes.push_back (std::pair <std::string, Lexer::Type> (lexeme, type));
@ -742,7 +742,7 @@ void CLI::addArg (const std::string& arg, Lexer::Type type /* = Lexer::Type::wor
{
// How often have I said to you that when you have eliminated the
// impossible, whatever remains, however improbable, must be the truth?
std::vector <std::pair <std::string, Lexer::Type> >::iterator l;
std::vector <std::pair <std::string, Lexer::Type>>::iterator l;
for (l = lexemes.begin (); l != lexemes.end (); ++l)
_original_args.push_back (l->first);
}
@ -1388,7 +1388,7 @@ void CLI::findIDs ()
if (raw.find_first_not_of ("0123456789,-") == std::string::npos)
{
// Container for min/max ID ranges.
std::vector <std::pair <int, int> > ranges;
std::vector <std::pair <int, int>> ranges;
// Split the ID list into elements.
std::vector <std::string> elements;
@ -1467,7 +1467,7 @@ void CLI::findIDs ()
a->tag ("ID");
// Save the ranges.
std::vector <std::pair <int, int> >::iterator r;
std::vector <std::pair <int, int>>::iterator r;
for (r = ranges.begin (); r != ranges.end (); ++r)
_id_ranges.push_back (*r);
}
@ -1576,7 +1576,7 @@ void CLI::insertIDExpr ()
reconstructed.push_back (openParen);
// Add all ID ranges.
std::vector <std::pair <int, int> >::iterator r;
std::vector <std::pair <int, int>>::iterator r;
for (r = _id_ranges.begin (); r != _id_ranges.end (); ++r)
{
if (r != _id_ranges.begin ())
@ -2375,17 +2375,17 @@ bool CLI::isName (const std::string& raw) const
////////////////////////////////////////////////////////////////////////////////
bool CLI::disqualifyInsufficientTerms (
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
const std::vector <std::pair <std::string, Lexer::Type>>& lexemes) const
{
return lexemes.size () < 3 ? true : false;
}
////////////////////////////////////////////////////////////////////////////////
bool CLI::disqualifyNoOps (
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
const std::vector <std::pair <std::string, Lexer::Type>>& lexemes) const
{
bool foundOP = false;
std::vector <std::pair <std::string, Lexer::Type> >::const_iterator l;
std::vector <std::pair <std::string, Lexer::Type>>::const_iterator l;
for (l = lexemes.begin (); l != lexemes.end (); ++l)
if (l->second == Lexer::Type::op)
foundOP = true;
@ -2395,13 +2395,13 @@ bool CLI::disqualifyNoOps (
////////////////////////////////////////////////////////////////////////////////
bool CLI::disqualifyOnlyParenOps (
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
const std::vector <std::pair <std::string, Lexer::Type>>& lexemes) const
{
int opCount = 0;
int opSugarCount = 0;
int opParenCount = 0;
std::vector <std::pair <std::string, Lexer::Type> >::const_iterator l;
std::vector <std::pair <std::string, Lexer::Type>>::const_iterator l;
for (l = lexemes.begin (); l != lexemes.end (); ++l)
{
if (l->second == Lexer::Type::op)
@ -2431,7 +2431,7 @@ bool CLI::disqualifyOnlyParenOps (
// as there are no operators in between, which includes syntactic sugar that
// hides operators.
bool CLI::disqualifyFirstLastBinary (
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
const std::vector <std::pair <std::string, Lexer::Type>>& lexemes) const
{
bool firstBinary = false;
bool lastBinary = false;
@ -2450,7 +2450,7 @@ bool CLI::disqualifyFirstLastBinary (
////////////////////////////////////////////////////////////////////////////////
// Disqualify terms when there operators hidden by syntactic sugar.
bool CLI::disqualifySugarFree (
const std::vector <std::pair <std::string, Lexer::Type> >& lexemes) const
const std::vector <std::pair <std::string, Lexer::Type>>& lexemes) const
{
bool sugared = true;
for (unsigned int i = 1; i < lexemes.size () - 1; ++i)

View file

@ -128,11 +128,11 @@ private:
bool isOperator (const std::string&) const;
bool isName (const std::string&) const;
bool disqualifyInsufficientTerms (const std::vector <std::pair <std::string, Lexer::Type> >&) const;
bool disqualifyNoOps (const std::vector <std::pair <std::string, Lexer::Type> >&) const;
bool disqualifyOnlyParenOps (const std::vector <std::pair <std::string, Lexer::Type> >&) const;
bool disqualifyFirstLastBinary (const std::vector <std::pair <std::string, Lexer::Type> >&) const;
bool disqualifySugarFree (const std::vector <std::pair <std::string, Lexer::Type> >&) const;
bool disqualifyInsufficientTerms (const std::vector <std::pair <std::string, Lexer::Type>>&) const;
bool disqualifyNoOps (const std::vector <std::pair <std::string, Lexer::Type>>&) const;
bool disqualifyOnlyParenOps (const std::vector <std::pair <std::string, Lexer::Type>>&) const;
bool disqualifyFirstLastBinary (const std::vector <std::pair <std::string, Lexer::Type>>&) const;
bool disqualifySugarFree (const std::vector <std::pair <std::string, Lexer::Type>>&) const;
public:
std::multimap <std::string, std::string> _entities;
@ -140,7 +140,7 @@ public:
std::vector <std::string> _original_args;
std::vector <A> _args;
std::vector <std::pair <int, int> > _id_ranges;
std::vector <std::pair <int, int>> _id_ranges;
std::vector <std::string> _uuid_list;
bool _strict;
bool _terminated;

View file

@ -127,7 +127,7 @@ void Eval::evaluateInfixExpression (const std::string& e, Variant& v) const
// Reduce e to a vector of tokens.
Lexer l (e);
l.ambiguity (_ambiguity);
std::vector <std::pair <std::string, Lexer::Type> > tokens;
std::vector <std::pair <std::string, Lexer::Type>> tokens;
std::string token;
Lexer::Type type;
while (l.token (token, type))
@ -155,7 +155,7 @@ void Eval::evaluatePostfixExpression (const std::string& e, Variant& v) const
// Reduce e to a vector of tokens.
Lexer l (e);
l.ambiguity (_ambiguity);
std::vector <std::pair <std::string, Lexer::Type> > tokens;
std::vector <std::pair <std::string, Lexer::Type>> tokens;
std::string token;
Lexer::Type type;
while (l.token (token, type))
@ -236,7 +236,7 @@ void Eval::getBinaryOperators (std::vector <std::string>& all)
////////////////////////////////////////////////////////////////////////////////
void Eval::evaluatePostfixStack (
const std::vector <std::pair <std::string, Lexer::Type> >& tokens,
const std::vector <std::pair <std::string, Lexer::Type>>& tokens,
Variant& result) const
{
if (tokens.size () == 0)
@ -245,7 +245,7 @@ void Eval::evaluatePostfixStack (
// This is stack used by the postfix evaluator.
std::vector <Variant> values;
std::vector <std::pair <std::string, Lexer::Type> >::const_iterator token;
std::vector <std::pair <std::string, Lexer::Type>>::const_iterator token;
for (token = tokens.begin (); token != tokens.end (); ++token)
{
// Unary operators.
@ -444,7 +444,7 @@ void Eval::evaluatePostfixStack (
// Primitive --> "(" Logical ")" | Variant
//
void Eval::infixParse (
std::vector <std::pair <std::string, Lexer::Type> >& infix) const
std::vector <std::pair <std::string, Lexer::Type>>& infix) const
{
unsigned int i = 0;
parseLogical (infix, i);
@ -453,7 +453,7 @@ void Eval::infixParse (
////////////////////////////////////////////////////////////////////////////////
// Logical --> Regex {( "and" | "or" | "xor" ) Regex}
bool Eval::parseLogical (
std::vector <std::pair <std::string, Lexer::Type> >& infix,
std::vector <std::pair <std::string, Lexer::Type>>& infix,
unsigned int &i) const
{
if (i < infix.size () &&
@ -479,7 +479,7 @@ bool Eval::parseLogical (
////////////////////////////////////////////////////////////////////////////////
// Regex --> Equality {( "~" | "!~" ) Equality}
bool Eval::parseRegex (
std::vector <std::pair <std::string, Lexer::Type> >& infix,
std::vector <std::pair <std::string, Lexer::Type>>& infix,
unsigned int &i) const
{
if (i < infix.size () &&
@ -504,7 +504,7 @@ bool Eval::parseRegex (
////////////////////////////////////////////////////////////////////////////////
// Equality --> Comparative {( "==" | "=" | "!==" | "!=" ) Comparative}
bool Eval::parseEquality (
std::vector <std::pair <std::string, Lexer::Type> >& infix,
std::vector <std::pair <std::string, Lexer::Type>>& infix,
unsigned int &i) const
{
if (i < infix.size () &&
@ -531,7 +531,7 @@ bool Eval::parseEquality (
////////////////////////////////////////////////////////////////////////////////
// Comparative --> Arithmetic {( "<=" | "<" | ">=" | ">" ) Arithmetic}
bool Eval::parseComparative (
std::vector <std::pair <std::string, Lexer::Type> >& infix,
std::vector <std::pair <std::string, Lexer::Type>>& infix,
unsigned int &i) const
{
if (i < infix.size () &&
@ -558,7 +558,7 @@ bool Eval::parseComparative (
////////////////////////////////////////////////////////////////////////////////
// Arithmetic --> Geometric {( "+" | "-" ) Geometric}
bool Eval::parseArithmetic (
std::vector <std::pair <std::string, Lexer::Type> >& infix,
std::vector <std::pair <std::string, Lexer::Type>>& infix,
unsigned int &i) const
{
if (i < infix.size () &&
@ -583,7 +583,7 @@ bool Eval::parseArithmetic (
////////////////////////////////////////////////////////////////////////////////
// Geometric --> Tag {( "*" | "/" | "%" ) Tag}
bool Eval::parseGeometric (
std::vector <std::pair <std::string, Lexer::Type> >& infix,
std::vector <std::pair <std::string, Lexer::Type>>& infix,
unsigned int &i) const
{
if (i < infix.size () &&
@ -609,7 +609,7 @@ bool Eval::parseGeometric (
////////////////////////////////////////////////////////////////////////////////
// Tag --> Unary {( "_hastag_" | "_notag_" ) Unary}
bool Eval::parseTag (
std::vector <std::pair <std::string, Lexer::Type> >& infix,
std::vector <std::pair <std::string, Lexer::Type>>& infix,
unsigned int &i) const
{
if (i < infix.size () &&
@ -634,7 +634,7 @@ bool Eval::parseTag (
////////////////////////////////////////////////////////////////////////////////
// Unary --> [( "-" | "+" | "!" )] Exponent
bool Eval::parseUnary (
std::vector <std::pair <std::string, Lexer::Type> >& infix,
std::vector <std::pair <std::string, Lexer::Type>>& infix,
unsigned int &i) const
{
if (i < infix.size ())
@ -661,7 +661,7 @@ bool Eval::parseUnary (
////////////////////////////////////////////////////////////////////////////////
// Exponent --> Primitive ["^" Primitive]
bool Eval::parseExponent (
std::vector <std::pair <std::string, Lexer::Type> >& infix,
std::vector <std::pair <std::string, Lexer::Type>>& infix,
unsigned int& i) const
{
if (i < infix.size () &&
@ -685,7 +685,7 @@ bool Eval::parseExponent (
////////////////////////////////////////////////////////////////////////////////
// Primitive --> "(" Logical ")" | Variant
bool Eval::parsePrimitive (
std::vector <std::pair <std::string, Lexer::Type> >& infix,
std::vector <std::pair <std::string, Lexer::Type>>& infix,
unsigned int &i) const
{
if (i < infix.size ())
@ -767,24 +767,24 @@ bool Eval::parsePrimitive (
// Exit.
//
void Eval::infixToPostfix (
std::vector <std::pair <std::string, Lexer::Type> >& infix) const
std::vector <std::pair <std::string, Lexer::Type>>& infix) const
{
// Short circuit.
if (infix.size () == 1)
return;
// Result.
std::vector <std::pair <std::string, Lexer::Type> > postfix;
std::vector <std::pair <std::string, Lexer::Type>> postfix;
// Shunting yard.
std::vector <std::pair <std::string, Lexer::Type> > op_stack;
std::vector <std::pair <std::string, Lexer::Type>> op_stack;
// Operator characteristics.
char type;
unsigned int precedence;
char associativity;
std::vector <std::pair <std::string, Lexer::Type> >::iterator token;
std::vector <std::pair <std::string, Lexer::Type>>::iterator token;
for (token = infix.begin (); token != infix.end (); ++token)
{
if (token->second == Lexer::Type::op &&
@ -866,7 +866,7 @@ bool Eval::identifyOperator (
////////////////////////////////////////////////////////////////////////////////
std::string Eval::dump (
std::vector <std::pair <std::string, Lexer::Type> >& tokens) const
std::vector <std::pair <std::string, Lexer::Type>>& tokens) const
{
// Set up a color mapping.
std::map <Lexer::Type, Color> color_map;
@ -880,7 +880,7 @@ std::string Eval::dump (
color_map[Lexer::Type::duration] = Color ("rgb531 on gray6");
std::string output;
std::vector <std::pair <std::string, Lexer::Type> >::const_iterator i;
std::vector <std::pair <std::string, Lexer::Type>>::const_iterator i;
for (i = tokens.begin (); i != tokens.end (); ++i)
{
if (i != tokens.begin ())

View file

@ -53,28 +53,28 @@ public:
static void getBinaryOperators (std::vector <std::string>&);
private:
void evaluatePostfixStack (const std::vector <std::pair <std::string, Lexer::Type> >&, Variant&) const;
void infixToPostfix (std::vector <std::pair <std::string, Lexer::Type> >&) const;
void infixParse (std::vector <std::pair <std::string, Lexer::Type> >&) const;
bool parseLogical (std::vector <std::pair <std::string, Lexer::Type> >&, unsigned int &) const;
bool parseRegex (std::vector <std::pair <std::string, Lexer::Type> >&, unsigned int &) const;
bool parseEquality (std::vector <std::pair <std::string, Lexer::Type> >&, unsigned int &) const;
bool parseComparative (std::vector <std::pair <std::string, Lexer::Type> >&, unsigned int &) const;
bool parseArithmetic (std::vector <std::pair <std::string, Lexer::Type> >&, unsigned int &) const;
bool parseGeometric (std::vector <std::pair <std::string, Lexer::Type> >&, unsigned int &) const;
bool parseTag (std::vector <std::pair <std::string, Lexer::Type> >&, unsigned int &) const;
bool parseUnary (std::vector <std::pair <std::string, Lexer::Type> >&, unsigned int &) const;
bool parseExponent (std::vector <std::pair <std::string, Lexer::Type> >&, unsigned int &) const;
bool parsePrimitive (std::vector <std::pair <std::string, Lexer::Type> >&, unsigned int &) const;
void evaluatePostfixStack (const std::vector <std::pair <std::string, Lexer::Type>>&, Variant&) const;
void infixToPostfix (std::vector <std::pair <std::string, Lexer::Type>>&) const;
void infixParse (std::vector <std::pair <std::string, Lexer::Type>>&) const;
bool parseLogical (std::vector <std::pair <std::string, Lexer::Type>>&, unsigned int &) const;
bool parseRegex (std::vector <std::pair <std::string, Lexer::Type>>&, unsigned int &) const;
bool parseEquality (std::vector <std::pair <std::string, Lexer::Type>>&, unsigned int &) const;
bool parseComparative (std::vector <std::pair <std::string, Lexer::Type>>&, unsigned int &) const;
bool parseArithmetic (std::vector <std::pair <std::string, Lexer::Type>>&, unsigned int &) const;
bool parseGeometric (std::vector <std::pair <std::string, Lexer::Type>>&, unsigned int &) const;
bool parseTag (std::vector <std::pair <std::string, Lexer::Type>>&, unsigned int &) const;
bool parseUnary (std::vector <std::pair <std::string, Lexer::Type>>&, unsigned int &) const;
bool parseExponent (std::vector <std::pair <std::string, Lexer::Type>>&, unsigned int &) const;
bool parsePrimitive (std::vector <std::pair <std::string, Lexer::Type>>&, unsigned int &) const;
bool identifyOperator (const std::string&, char&, unsigned int&, char&) const;
std::string dump (std::vector <std::pair <std::string, Lexer::Type> >&) const;
std::string dump (std::vector <std::pair <std::string, Lexer::Type>>&) const;
private:
std::vector <bool (*)(const std::string&, Variant&)> _sources;
bool _ambiguity;
bool _debug;
std::vector <std::pair <std::string, Lexer::Type> > _compiled;
std::vector <std::pair <std::string, Lexer::Type>> _compiled;
};

View file

@ -85,7 +85,7 @@ float Task::urgencyBlockingCoefficient = 0.0;
float Task::urgencyAgeCoefficient = 0.0;
float Task::urgencyAgeMax = 0.0;
std::map <std::string, std::vector <std::string> > Task::customOrder;
std::map <std::string, std::vector <std::string>> Task::customOrder;
static const std::string dummy ("");

View file

@ -42,7 +42,7 @@ public:
static bool regex;
static std::map <std::string, std::string> attributes; // name -> type
static std::map <std::string, float> coefficients;
static std::map <std::string, std::vector <std::string> > customOrder;
static std::map <std::string, std::vector <std::string>> customOrder;
static float urgencyProjectCoefficient;
static float urgencyActiveCoefficient;
static float urgencyScheduledCoefficient;

View file

@ -242,7 +242,7 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
// Compose column headers.
unsigned int max_lines = 0;
std::vector <std::vector <std::string> > headers;
std::vector <std::vector <std::string>> headers;
for (unsigned int c = 0; c < _columns.size (); ++c)
{
headers.push_back (std::vector <std::string> ());
@ -295,7 +295,7 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
// Compose, render columns, in sequence.
_rows = 0;
std::vector <std::vector <std::string> > cells;
std::vector <std::vector <std::string>> cells;
std::vector <int>::iterator s;
for (unsigned int s = 0; s < sequence.size (); ++s)
{

View file

@ -186,7 +186,7 @@ std::string ViewText::render ()
// Compose column headers.
unsigned int max_lines = 0;
std::vector <std::vector <std::string> > headers;
std::vector <std::vector <std::string>> headers;
for (unsigned int c = 0; c < _columns.size (); ++c)
{
headers.push_back (std::vector <std::string> ());
@ -238,7 +238,7 @@ std::string ViewText::render ()
// Compose, render columns, in sequence.
_rows = 0;
std::vector <std::vector <std::string> > cells;
std::vector <std::vector <std::string>> cells;
for (unsigned int row = 0; row < _data.size (); ++row)
{
max_lines = 0;

View file

@ -68,24 +68,24 @@ public:
std::string render ();
private:
std::vector <std::vector <std::string> > _data;
std::vector <std::vector <Color> > _color;
std::vector <Column*> _columns;
int _width;
int _left_margin;
Color _header;
Color _odd;
Color _even;
int _intra_padding;
Color _intra_odd;
Color _intra_even;
int _extra_padding;
Color _extra_odd;
Color _extra_even;
int _truncate_lines;
int _truncate_rows;
int _lines;
int _rows;
std::vector <std::vector <std::string>> _data;
std::vector <std::vector <Color>> _color;
std::vector <Column*> _columns;
int _width;
int _left_margin;
Color _header;
Color _odd;
Color _even;
int _intra_padding;
Color _intra_odd;
Color _intra_even;
int _extra_padding;
Color _extra_odd;
Color _extra_even;
int _truncate_lines;
int _truncate_rows;
int _lines;
int _rows;
};
#endif

View file

@ -366,7 +366,7 @@ int CmdCalendar::execute (std::string& output)
holTable.colorHeader (color_label);
Config::const_iterator it;
std::map <time_t, std::vector<std::string> > hm; // we need to store multiple holidays per day
std::map <time_t, std::vector<std::string>> hm; // we need to store multiple holidays per day
for (it = context.config.begin (); it != context.config.end (); ++it)
if (it->first.substr (0, 8) == "holiday.")
if (it->first.substr (it->first.size () - 4) == "name")
@ -389,7 +389,7 @@ int CmdCalendar::execute (std::string& output)
if (format == "")
format = context.config.get ("dateformat");
std::map <time_t, std::vector<std::string> >::iterator hm_it;
std::map <time_t, std::vector<std::string>>::iterator hm_it;
for (hm_it = hm.begin(); hm_it != hm.end(); ++hm_it)
{
std::vector <std::string> v = hm_it->second;

View file

@ -38,7 +38,7 @@ int main (int argc, char** argv)
{
UnitTest t (765);
std::vector <std::pair <std::string, Lexer::Type> > tokens;
std::vector <std::pair <std::string, Lexer::Type>> tokens;
std::string token;
Lexer::Type type;