mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 04:27:20 +02:00
C++11: N1984 auto
This commit is contained in:
parent
7bbc794d3a
commit
e8d04bdce6
24 changed files with 77 additions and 77 deletions
14
src/CLI.cpp
14
src/CLI.cpp
|
@ -230,7 +230,7 @@ void CLI::getOverride (int argc, const char** argv, std::string& home, File& rc)
|
||||||
rc = raw.substr (3);
|
rc = raw.substr (3);
|
||||||
|
|
||||||
home = ".";
|
home = ".";
|
||||||
std::string::size_type last_slash = rc._data.rfind ("/");
|
auto last_slash = rc._data.rfind ("/");
|
||||||
if (last_slash != std::string::npos)
|
if (last_slash != std::string::npos)
|
||||||
home = rc.parent ();
|
home = rc.parent ();
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ void CLI::applyOverrides (int argc, const char** argv)
|
||||||
raw.length () > 3 &&
|
raw.length () > 3 &&
|
||||||
raw.substr (0, 3) == "rc.")
|
raw.substr (0, 3) == "rc.")
|
||||||
{
|
{
|
||||||
std::string::size_type sep = raw.find ('=', 3);
|
auto sep = raw.find ('=', 3);
|
||||||
if (sep == std::string::npos)
|
if (sep == std::string::npos)
|
||||||
sep = raw.find (':', 3);
|
sep = raw.find (':', 3);
|
||||||
if (sep != std::string::npos)
|
if (sep != std::string::npos)
|
||||||
|
@ -445,7 +445,7 @@ void CLI::analyze (bool parse /* = true */, bool strict /* = false */)
|
||||||
a.tag ("BINARY");
|
a.tag ("BINARY");
|
||||||
|
|
||||||
std::string basename = "task";
|
std::string basename = "task";
|
||||||
std::string::size_type slash = raw.rfind ('/');
|
auto slash = raw.rfind ('/');
|
||||||
if (slash != std::string::npos)
|
if (slash != std::string::npos)
|
||||||
basename = raw.substr (slash + 1);
|
basename = raw.substr (slash + 1);
|
||||||
|
|
||||||
|
@ -808,7 +808,7 @@ void CLI::findOverrides ()
|
||||||
}
|
}
|
||||||
else if (isConfigOverride (raw))
|
else if (isConfigOverride (raw))
|
||||||
{
|
{
|
||||||
std::string::size_type sep = raw.find ('=', 3);
|
auto sep = raw.find ('=', 3);
|
||||||
if (sep == std::string::npos)
|
if (sep == std::string::npos)
|
||||||
sep = raw.find (':', 3);
|
sep = raw.find (':', 3);
|
||||||
if (sep != std::string::npos)
|
if (sep != std::string::npos)
|
||||||
|
@ -2236,8 +2236,8 @@ bool CLI::isSubstitution (const std::string& raw) const
|
||||||
// <attr>.[~]<mod>[:=]...
|
// <attr>.[~]<mod>[:=]...
|
||||||
bool CLI::isAttribute (const std::string& raw) const
|
bool CLI::isAttribute (const std::string& raw) const
|
||||||
{
|
{
|
||||||
std::string::size_type colon = raw.find (":");
|
auto colon = raw.find (":");
|
||||||
std::string::size_type equal = raw.find ("=");
|
auto equal = raw.find ("=");
|
||||||
|
|
||||||
std::string attr = "";
|
std::string attr = "";
|
||||||
if (colon != std::string::npos)
|
if (colon != std::string::npos)
|
||||||
|
@ -2251,7 +2251,7 @@ bool CLI::isAttribute (const std::string& raw) const
|
||||||
if (! isName (attr))
|
if (! isName (attr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string::size_type dot = attr.find (".");
|
auto dot = attr.find (".");
|
||||||
std::string mod = "";
|
std::string mod = "";
|
||||||
if (dot != std::string::npos)
|
if (dot != std::string::npos)
|
||||||
{
|
{
|
||||||
|
|
|
@ -531,7 +531,7 @@ void Config::parse (const std::string& input, int nest /* = 1 */)
|
||||||
for (auto& line : lines)
|
for (auto& line : lines)
|
||||||
{
|
{
|
||||||
// Remove comments.
|
// Remove comments.
|
||||||
std::string::size_type pound = line.find ("#"); // no i18n
|
auto pound = line.find ("#"); // no i18n
|
||||||
if (pound != std::string::npos)
|
if (pound != std::string::npos)
|
||||||
line = line.substr (0, pound);
|
line = line.substr (0, pound);
|
||||||
|
|
||||||
|
@ -540,7 +540,7 @@ void Config::parse (const std::string& input, int nest /* = 1 */)
|
||||||
// Skip empty lines.
|
// Skip empty lines.
|
||||||
if (line.length () > 0)
|
if (line.length () > 0)
|
||||||
{
|
{
|
||||||
std::string::size_type equal = line.find ("="); // no i18n
|
auto equal = line.find ("="); // no i18n
|
||||||
if (equal != std::string::npos)
|
if (equal != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string key = trim (line.substr (0, equal), " \t"); // no i18n
|
std::string key = trim (line.substr (0, equal), " \t"); // no i18n
|
||||||
|
@ -550,7 +550,7 @@ void Config::parse (const std::string& input, int nest /* = 1 */)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string::size_type include = line.find ("include"); // no i18n.
|
auto include = line.find ("include"); // no i18n.
|
||||||
if (include != std::string::npos)
|
if (include != std::string::npos)
|
||||||
{
|
{
|
||||||
Path included (trim (line.substr (include + 7), " \t"));
|
Path included (trim (line.substr (include + 7), " \t"));
|
||||||
|
@ -575,7 +575,7 @@ void Config::parse (const std::string& input, int nest /* = 1 */)
|
||||||
void Config::createDefaultRC (const std::string& rc, const std::string& data)
|
void Config::createDefaultRC (const std::string& rc, const std::string& data)
|
||||||
{
|
{
|
||||||
// Override data.location in the defaults.
|
// Override data.location in the defaults.
|
||||||
std::string::size_type loc = _defaults.find ("data.location=~/.task");
|
auto loc = _defaults.find ("data.location=~/.task");
|
||||||
// loc+0^ +14^ +21^
|
// loc+0^ +14^ +21^
|
||||||
|
|
||||||
Date now;
|
Date now;
|
||||||
|
|
|
@ -175,7 +175,7 @@ bool Directory::up ()
|
||||||
if (_data == "/")
|
if (_data == "/")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string::size_type slash = _data.rfind ('/');
|
auto slash = _data.rfind ('/');
|
||||||
if (slash == 0)
|
if (slash == 0)
|
||||||
{
|
{
|
||||||
_data = "/"; // Root dir should retain the slash.
|
_data = "/"; // Root dir should retain the slash.
|
||||||
|
|
|
@ -299,7 +299,7 @@ std::string Duration::formatISO () const
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Duration::parse (const std::string& input, std::string::size_type& start)
|
bool Duration::parse (const std::string& input, std::string::size_type& start)
|
||||||
{
|
{
|
||||||
std::string::size_type original_start = start;
|
auto original_start = start;
|
||||||
Nibbler n (input.substr (start));
|
Nibbler n (input.substr (start));
|
||||||
|
|
||||||
// Static and so preserved between calls.
|
// Static and so preserved between calls.
|
||||||
|
|
|
@ -129,7 +129,7 @@ void ISO8601d::ambiguity (bool value)
|
||||||
//
|
//
|
||||||
bool ISO8601d::parse (const std::string& input, std::string::size_type& start)
|
bool ISO8601d::parse (const std::string& input, std::string::size_type& start)
|
||||||
{
|
{
|
||||||
std::string::size_type i = start;
|
auto i = start;
|
||||||
Nibbler n (input.substr (i));
|
Nibbler n (input.substr (i));
|
||||||
|
|
||||||
if (parse_date_time_ext (n) || // Most complex first.
|
if (parse_date_time_ext (n) || // Most complex first.
|
||||||
|
@ -749,7 +749,7 @@ ISO8601p::operator time_t () const
|
||||||
//
|
//
|
||||||
bool ISO8601p::parse (const std::string& input, std::string::size_type& start)
|
bool ISO8601p::parse (const std::string& input, std::string::size_type& start)
|
||||||
{
|
{
|
||||||
std::string::size_type i = start;
|
auto i = start;
|
||||||
Nibbler n (input.substr (i));
|
Nibbler n (input.substr (i));
|
||||||
|
|
||||||
if (parse_designated (n))
|
if (parse_designated (n))
|
||||||
|
|
|
@ -150,7 +150,7 @@ bool Msg::parse (const std::string& input)
|
||||||
split (lines, input.substr (0, separator), '\n');
|
split (lines, input.substr (0, separator), '\n');
|
||||||
for (auto& i : lines)
|
for (auto& i : lines)
|
||||||
{
|
{
|
||||||
std::string::size_type delimiter = i.find (':');
|
auto delimiter = i.find (':');
|
||||||
if (delimiter == std::string::npos)
|
if (delimiter == std::string::npos)
|
||||||
throw std::string ("ERROR: Malformed message header '") + i + "'";
|
throw std::string ("ERROR: Malformed message header '") + i + "'";
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ bool Nibbler::getUntil (char c, std::string& result)
|
||||||
{
|
{
|
||||||
if (_cursor < _length)
|
if (_cursor < _length)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _input.find (c, _cursor);
|
auto i = _input.find (c, _cursor);
|
||||||
if (i != std::string::npos)
|
if (i != std::string::npos)
|
||||||
{
|
{
|
||||||
result = _input.substr (_cursor, i - _cursor);
|
result = _input.substr (_cursor, i - _cursor);
|
||||||
|
@ -114,7 +114,7 @@ bool Nibbler::getUntil (const std::string& terminator, std::string& result)
|
||||||
{
|
{
|
||||||
if (_cursor < _length)
|
if (_cursor < _length)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _input.find (terminator, _cursor);
|
auto i = _input.find (terminator, _cursor);
|
||||||
if (i != std::string::npos)
|
if (i != std::string::npos)
|
||||||
{
|
{
|
||||||
result = _input.substr (_cursor, i - _cursor);
|
result = _input.substr (_cursor, i - _cursor);
|
||||||
|
@ -164,7 +164,7 @@ bool Nibbler::getUntilOneOf (const std::string& chars, std::string& result)
|
||||||
{
|
{
|
||||||
if (_cursor < _length)
|
if (_cursor < _length)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _input.find_first_of (chars, _cursor);
|
auto i = _input.find_first_of (chars, _cursor);
|
||||||
if (i != std::string::npos)
|
if (i != std::string::npos)
|
||||||
{
|
{
|
||||||
result = _input.substr (_cursor, i - _cursor);
|
result = _input.substr (_cursor, i - _cursor);
|
||||||
|
@ -238,7 +238,7 @@ bool Nibbler::getQuoted (
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::string::size_type i = _cursor; i < _length; ++i)
|
for (auto i = _cursor; i < _length; ++i)
|
||||||
{
|
{
|
||||||
current = _input[i];
|
current = _input[i];
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ bool Nibbler::getDigit (int& result)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Nibbler::getDigit6 (int& result)
|
bool Nibbler::getDigit6 (int& result)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
if (i < _length &&
|
if (i < _length &&
|
||||||
_length - i >= 6)
|
_length - i >= 6)
|
||||||
{
|
{
|
||||||
|
@ -319,7 +319,7 @@ bool Nibbler::getDigit6 (int& result)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Nibbler::getDigit4 (int& result)
|
bool Nibbler::getDigit4 (int& result)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
if (i < _length &&
|
if (i < _length &&
|
||||||
_length - i >= 4)
|
_length - i >= 4)
|
||||||
{
|
{
|
||||||
|
@ -340,7 +340,7 @@ bool Nibbler::getDigit4 (int& result)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Nibbler::getDigit3 (int& result)
|
bool Nibbler::getDigit3 (int& result)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
if (i < _length &&
|
if (i < _length &&
|
||||||
_length - i >= 3)
|
_length - i >= 3)
|
||||||
{
|
{
|
||||||
|
@ -360,7 +360,7 @@ bool Nibbler::getDigit3 (int& result)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Nibbler::getDigit2 (int& result)
|
bool Nibbler::getDigit2 (int& result)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
if (i < _length &&
|
if (i < _length &&
|
||||||
_length - i >= 2)
|
_length - i >= 2)
|
||||||
{
|
{
|
||||||
|
@ -379,7 +379,7 @@ bool Nibbler::getDigit2 (int& result)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Nibbler::getInt (int& result)
|
bool Nibbler::getInt (int& result)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
|
|
||||||
if (i < _length)
|
if (i < _length)
|
||||||
{
|
{
|
||||||
|
@ -406,7 +406,7 @@ bool Nibbler::getInt (int& result)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Nibbler::getUnsignedInt (int& result)
|
bool Nibbler::getUnsignedInt (int& result)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
// TODO Potential for use of find_first_not_of
|
// TODO Potential for use of find_first_not_of
|
||||||
while (i < _length && Lexer::isDigit (_input[i]))
|
while (i < _length && Lexer::isDigit (_input[i]))
|
||||||
++i;
|
++i;
|
||||||
|
@ -439,7 +439,7 @@ bool Nibbler::getUnsignedInt (int& result)
|
||||||
//
|
//
|
||||||
bool Nibbler::getNumber (std::string& result)
|
bool Nibbler::getNumber (std::string& result)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
|
|
||||||
// [+-]?
|
// [+-]?
|
||||||
if (i < _length && (_input[i] == '-' || _input[i] == '+'))
|
if (i < _length && (_input[i] == '-' || _input[i] == '+'))
|
||||||
|
@ -525,7 +525,7 @@ bool Nibbler::getNumber (double &result)
|
||||||
//
|
//
|
||||||
bool Nibbler::getUnsignedNumber (double& result)
|
bool Nibbler::getUnsignedNumber (double& result)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
|
|
||||||
// digit+
|
// digit+
|
||||||
if (i < _length && Lexer::isDigit (_input[i]))
|
if (i < _length && Lexer::isDigit (_input[i]))
|
||||||
|
@ -619,7 +619,7 @@ bool Nibbler::getRx (const std::string& regex, std::string& result)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Nibbler::getUUID (std::string& result)
|
bool Nibbler::getUUID (std::string& result)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
|
|
||||||
if (i < _length &&
|
if (i < _length &&
|
||||||
_length - i >= 36)
|
_length - i >= 36)
|
||||||
|
@ -705,7 +705,7 @@ bool Nibbler::getPartialUUID (std::string& result)
|
||||||
// 19980119T070000Z = YYYYMMDDThhmmssZ
|
// 19980119T070000Z = YYYYMMDDThhmmssZ
|
||||||
bool Nibbler::getDateISO (time_t& t)
|
bool Nibbler::getDateISO (time_t& t)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
|
|
||||||
if (i < _length &&
|
if (i < _length &&
|
||||||
_length - i >= 16)
|
_length - i >= 16)
|
||||||
|
@ -815,7 +815,7 @@ bool Nibbler::parseDigits(std::string::size_type& i,
|
||||||
#ifdef NIBBLER_FEATURE_DATE
|
#ifdef NIBBLER_FEATURE_DATE
|
||||||
bool Nibbler::getDate (const std::string& format, time_t& t)
|
bool Nibbler::getDate (const std::string& format, time_t& t)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
|
|
||||||
int month = -1; // So we can check later.
|
int month = -1; // So we can check later.
|
||||||
int day = -1;
|
int day = -1;
|
||||||
|
@ -998,7 +998,7 @@ bool Nibbler::getOneOf (
|
||||||
// A name is a string of alpha-numeric characters.
|
// A name is a string of alpha-numeric characters.
|
||||||
bool Nibbler::getName (std::string& result)
|
bool Nibbler::getName (std::string& result)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
|
|
||||||
if (i < _length)
|
if (i < _length)
|
||||||
{
|
{
|
||||||
|
@ -1030,7 +1030,7 @@ bool Nibbler::getName (std::string& result)
|
||||||
// A word is a contiguous string of non-space, non-digit, non-punct characters.
|
// A word is a contiguous string of non-space, non-digit, non-punct characters.
|
||||||
bool Nibbler::getWord (std::string& result)
|
bool Nibbler::getWord (std::string& result)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _cursor;
|
auto i = _cursor;
|
||||||
|
|
||||||
if (i < _length)
|
if (i < _length)
|
||||||
{
|
{
|
||||||
|
@ -1083,7 +1083,7 @@ bool Nibbler::skipAll (char c)
|
||||||
{
|
{
|
||||||
if (_cursor < _length)
|
if (_cursor < _length)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _input.find_first_not_of (c, _cursor);
|
auto i = _input.find_first_not_of (c, _cursor);
|
||||||
if (i == _cursor)
|
if (i == _cursor)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1156,7 +1156,7 @@ bool Nibbler::skipAllOneOf (const std::string& chars)
|
||||||
{
|
{
|
||||||
if (_cursor < _length)
|
if (_cursor < _length)
|
||||||
{
|
{
|
||||||
std::string::size_type i = _input.find_first_not_of (chars, _cursor);
|
auto i = _input.find_first_not_of (chars, _cursor);
|
||||||
if (i == _cursor)
|
if (i == _cursor)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ std::string Path::name () const
|
||||||
{
|
{
|
||||||
if (_data.length ())
|
if (_data.length ())
|
||||||
{
|
{
|
||||||
std::string::size_type slash = _data.rfind ('/');
|
auto slash = _data.rfind ('/');
|
||||||
if (slash != std::string::npos)
|
if (slash != std::string::npos)
|
||||||
return _data.substr (slash + 1, std::string::npos);
|
return _data.substr (slash + 1, std::string::npos);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ std::string Path::parent () const
|
||||||
{
|
{
|
||||||
if (_data.length ())
|
if (_data.length ())
|
||||||
{
|
{
|
||||||
std::string::size_type slash = _data.rfind ('/');
|
auto slash = _data.rfind ('/');
|
||||||
if (slash != std::string::npos)
|
if (slash != std::string::npos)
|
||||||
return _data.substr (0, slash);
|
return _data.substr (0, slash);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ std::string Path::extension () const
|
||||||
{
|
{
|
||||||
if (_data.length ())
|
if (_data.length ())
|
||||||
{
|
{
|
||||||
std::string::size_type dot = _data.rfind ('.');
|
auto dot = _data.rfind ('.');
|
||||||
if (dot != std::string::npos)
|
if (dot != std::string::npos)
|
||||||
return _data.substr (dot + 1, std::string::npos);
|
return _data.substr (dot + 1, std::string::npos);
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ std::string Path::expand (const std::string& in)
|
||||||
{
|
{
|
||||||
std::string copy = in;
|
std::string copy = in;
|
||||||
|
|
||||||
std::string::size_type tilde = copy.find ("~");
|
auto tilde = copy.find ("~");
|
||||||
std::string::size_type slash;
|
std::string::size_type slash;
|
||||||
|
|
||||||
if (tilde != std::string::npos)
|
if (tilde != std::string::npos)
|
||||||
|
|
|
@ -464,7 +464,7 @@ const std::string TF2::dump ()
|
||||||
|
|
||||||
// File label.
|
// File label.
|
||||||
std::string label;
|
std::string label;
|
||||||
std::string::size_type slash = _file._data.rfind ('/');
|
auto slash = _file._data.rfind ('/');
|
||||||
if (slash != std::string::npos)
|
if (slash != std::string::npos)
|
||||||
label = rightJustify (_file._data.substr (slash + 1), 14);
|
label = rightJustify (_file._data.substr (slash + 1), 14);
|
||||||
|
|
||||||
|
@ -791,7 +791,7 @@ void TDB2::revert_undo (
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract identifying uuid.
|
// Extract identifying uuid.
|
||||||
std::string::size_type uuidAtt = current.find ("uuid:\"");
|
auto uuidAtt = current.find ("uuid:\"");
|
||||||
if (uuidAtt != std::string::npos)
|
if (uuidAtt != std::string::npos)
|
||||||
uuid = current.substr (uuidAtt + 6, 36); // "uuid:"<uuid>" --> <uuid>
|
uuid = current.substr (uuidAtt + 6, 36); // "uuid:"<uuid>" --> <uuid>
|
||||||
else
|
else
|
||||||
|
|
14
src/Task.cpp
14
src/Task.cpp
|
@ -1393,7 +1393,7 @@ void Task::validate (bool applyDefault /* = true */)
|
||||||
if (var.first.substr (0, 4) == "uda." &&
|
if (var.first.substr (0, 4) == "uda." &&
|
||||||
var.first.find (".default") != std::string::npos)
|
var.first.find (".default") != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string::size_type period = var.first.find ('.', 4);
|
auto period = var.first.find ('.', 4);
|
||||||
if (period != std::string::npos)
|
if (period != std::string::npos)
|
||||||
udas.push_back (var.first.substr (4, period - 4));
|
udas.push_back (var.first.substr (4, period - 4));
|
||||||
}
|
}
|
||||||
|
@ -1543,9 +1543,9 @@ int Task::determineVersion (const std::string& line)
|
||||||
// uuid status [tags] [attributes] [annotations] description\n
|
// uuid status [tags] [attributes] [annotations] description\n
|
||||||
//
|
//
|
||||||
// Scan for the number of [] pairs.
|
// Scan for the number of [] pairs.
|
||||||
std::string::size_type tagAtts = line.find ("] [", 0);
|
auto tagAtts = line.find ("] [", 0);
|
||||||
std::string::size_type attsAnno = line.find ("] [", tagAtts + 1);
|
auto attsAnno = line.find ("] [", tagAtts + 1);
|
||||||
std::string::size_type annoDesc = line.find ("] ", attsAnno + 1);
|
auto annoDesc = line.find ("] ", attsAnno + 1);
|
||||||
if (tagAtts != std::string::npos &&
|
if (tagAtts != std::string::npos &&
|
||||||
attsAnno != std::string::npos &&
|
attsAnno != std::string::npos &&
|
||||||
annoDesc != std::string::npos)
|
annoDesc != std::string::npos)
|
||||||
|
@ -1630,7 +1630,7 @@ float Task::urgency_c () const
|
||||||
if (var.first.substr (0, 13) == "urgency.user.")
|
if (var.first.substr (0, 13) == "urgency.user.")
|
||||||
{
|
{
|
||||||
// urgency.user.project.<project>.coefficient
|
// urgency.user.project.<project>.coefficient
|
||||||
std::string::size_type end = std::string::npos;
|
auto end = std::string::npos;
|
||||||
if (var.first.substr (13, 8) == "project." &&
|
if (var.first.substr (13, 8) == "project." &&
|
||||||
(end = var.first.find (".coefficient")) != std::string::npos)
|
(end = var.first.find (".coefficient")) != std::string::npos)
|
||||||
{
|
{
|
||||||
|
@ -1664,11 +1664,11 @@ float Task::urgency_c () const
|
||||||
{
|
{
|
||||||
// urgency.uda.<name>.coefficient
|
// urgency.uda.<name>.coefficient
|
||||||
// urgency.uda.<name>.<value>.coefficient
|
// urgency.uda.<name>.<value>.coefficient
|
||||||
std::string::size_type end = var.first.find (".coefficient");
|
auto end = var.first.find (".coefficient");
|
||||||
if (end != std::string::npos)
|
if (end != std::string::npos)
|
||||||
{
|
{
|
||||||
const std::string uda = var.first.substr (12, end - 12);
|
const std::string uda = var.first.substr (12, end - 12);
|
||||||
std::string::size_type dot = uda.find (".");
|
auto dot = uda.find (".");
|
||||||
if (dot == std::string::npos)
|
if (dot == std::string::npos)
|
||||||
{
|
{
|
||||||
// urgency.uda.<name>.coefficient
|
// urgency.uda.<name>.coefficient
|
||||||
|
|
|
@ -71,7 +71,7 @@ void ColumnProject::measure (Task& task, unsigned int& minimum, unsigned int& ma
|
||||||
|
|
||||||
if (_style == "parent")
|
if (_style == "parent")
|
||||||
{
|
{
|
||||||
std::string::size_type period = project.find ('.');
|
auto period = project.find ('.');
|
||||||
if (period != std::string::npos)
|
if (period != std::string::npos)
|
||||||
project = project.substr (0, period);
|
project = project.substr (0, period);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ void ColumnProject::render (
|
||||||
std::string project = task.get (_name);
|
std::string project = task.get (_name);
|
||||||
if (_style == "parent")
|
if (_style == "parent")
|
||||||
{
|
{
|
||||||
std::string::size_type period = project.find ('.');
|
auto period = project.find ('.');
|
||||||
if (period != std::string::npos)
|
if (period != std::string::npos)
|
||||||
project = project.substr (0, period);
|
project = project.substr (0, period);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ extern Context context;
|
||||||
Column* Column::factory (const std::string& name, const std::string& report)
|
Column* Column::factory (const std::string& name, const std::string& report)
|
||||||
{
|
{
|
||||||
// Decompose name into type and style.
|
// Decompose name into type and style.
|
||||||
std::string::size_type dot = name.find ('.');
|
auto dot = name.find ('.');
|
||||||
std::string column_name;
|
std::string column_name;
|
||||||
std::string column_style;
|
std::string column_style;
|
||||||
if (dot != std::string::npos)
|
if (dot != std::string::npos)
|
||||||
|
|
|
@ -593,7 +593,7 @@ void Chart::optimizeGrid ()
|
||||||
std::string::size_type ws;
|
std::string::size_type ws;
|
||||||
while ((ws = _grid.find (" \n")) != std::string::npos)
|
while ((ws = _grid.find (" \n")) != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string::size_type non_ws = ws;
|
auto non_ws = ws;
|
||||||
while (_grid[non_ws] == ' ')
|
while (_grid[non_ws] == ' ')
|
||||||
--non_ws;
|
--non_ws;
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,7 @@ int CmdCalendar::execute (std::string& output)
|
||||||
|
|
||||||
// If the executable was "cal" or equivalent, replace it with "task".
|
// If the executable was "cal" or equivalent, replace it with "task".
|
||||||
std::string executable = context.cli._args[0].attribute ("raw");
|
std::string executable = context.cli._args[0].attribute ("raw");
|
||||||
std::string::size_type cal = executable.find ("cal");
|
auto cal = executable.find ("cal");
|
||||||
if (cal != std::string::npos)
|
if (cal != std::string::npos)
|
||||||
executable = executable.substr (0, cal) + PACKAGE;
|
executable = executable.substr (0, cal) + PACKAGE;
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,8 @@ bool CmdConfig::setConfigVariable (std::string name, std::string value, bool con
|
||||||
for (auto& line : contents)
|
for (auto& line : contents)
|
||||||
{
|
{
|
||||||
// If there is a comment on the line, it must follow the pattern.
|
// If there is a comment on the line, it must follow the pattern.
|
||||||
std::string::size_type comment = line.find ("#");
|
auto comment = line.find ("#");
|
||||||
std::string::size_type pos = line.find (name + "=");
|
auto pos = line.find (name + "=");
|
||||||
|
|
||||||
if (pos != std::string::npos &&
|
if (pos != std::string::npos &&
|
||||||
(comment == std::string::npos ||
|
(comment == std::string::npos ||
|
||||||
|
@ -110,8 +110,8 @@ int CmdConfig::unsetConfigVariable (std::string name, bool confirmation /* = fal
|
||||||
bool lineDeleted = false;
|
bool lineDeleted = false;
|
||||||
|
|
||||||
// If there is a comment on the line, it must follow the pattern.
|
// If there is a comment on the line, it must follow the pattern.
|
||||||
std::string::size_type comment = line->find ("#");
|
auto comment = line->find ("#");
|
||||||
std::string::size_type pos = line->find (name + "=");
|
auto pos = line->find (name + "=");
|
||||||
|
|
||||||
if (pos != std::string::npos &&
|
if (pos != std::string::npos &&
|
||||||
(comment == std::string::npos ||
|
(comment == std::string::npos ||
|
||||||
|
|
|
@ -108,7 +108,7 @@ int CmdDenotate::execute (std::string& output)
|
||||||
{
|
{
|
||||||
for (auto i = annotations.begin (); i != annotations.end (); ++i)
|
for (auto i = annotations.begin (); i != annotations.end (); ++i)
|
||||||
{
|
{
|
||||||
std::string::size_type loc = find (i->second, pattern, sensitive);
|
auto loc = find (i->second, pattern, sensitive);
|
||||||
if (loc != std::string::npos)
|
if (loc != std::string::npos)
|
||||||
{
|
{
|
||||||
anno = i->second;
|
anno = i->second;
|
||||||
|
|
|
@ -285,7 +285,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||||
|
|
||||||
// Get credentials, but mask out the key.
|
// Get credentials, but mask out the key.
|
||||||
std::string credentials = context.config.get ("taskd.credentials");
|
std::string credentials = context.config.get ("taskd.credentials");
|
||||||
std::string::size_type last_slash = credentials.rfind ('/');
|
auto last_slash = credentials.rfind ('/');
|
||||||
if (last_slash != std::string::npos)
|
if (last_slash != std::string::npos)
|
||||||
credentials = credentials.substr (0, last_slash)
|
credentials = credentials.substr (0, last_slash)
|
||||||
+ "/"
|
+ "/"
|
||||||
|
|
|
@ -78,10 +78,10 @@ std::string CmdEdit::findValue (
|
||||||
const std::string& text,
|
const std::string& text,
|
||||||
const std::string& name)
|
const std::string& name)
|
||||||
{
|
{
|
||||||
std::string::size_type found = text.find (name);
|
auto found = text.find (name);
|
||||||
if (found != std::string::npos)
|
if (found != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string::size_type eol = text.find ("\n", found + 1);
|
auto eol = text.find ("\n", found + 1);
|
||||||
if (eol != std::string::npos)
|
if (eol != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string value = text.substr (
|
std::string value = text.substr (
|
||||||
|
@ -101,10 +101,10 @@ std::string CmdEdit::findMultilineValue (
|
||||||
const std::string& startMarker,
|
const std::string& startMarker,
|
||||||
const std::string& endMarker)
|
const std::string& endMarker)
|
||||||
{
|
{
|
||||||
std::string::size_type start = text.find (startMarker);
|
auto start = text.find (startMarker);
|
||||||
if (start != std::string::npos)
|
if (start != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string::size_type end = text.find (endMarker, start);
|
auto end = text.find (endMarker, start);
|
||||||
if (end != std::string::npos)
|
if (end != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string value = text.substr (start + startMarker.length (),
|
std::string value = text.substr (start + startMarker.length (),
|
||||||
|
@ -128,7 +128,7 @@ std::vector <std::string> CmdEdit::findValues (
|
||||||
found = text.find (name, found + 1);
|
found = text.find (name, found + 1);
|
||||||
if (found != std::string::npos)
|
if (found != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string::size_type eol = text.find ("\n", found + 1);
|
auto eol = text.find ("\n", found + 1);
|
||||||
if (eol != std::string::npos)
|
if (eol != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string value = text.substr (
|
std::string value = text.substr (
|
||||||
|
@ -612,14 +612,14 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||||
{
|
{
|
||||||
found += 14; // Length of "\n Annotation:".
|
found += 14; // Length of "\n Annotation:".
|
||||||
|
|
||||||
std::string::size_type eol = after.find ("\n", found + 1);
|
auto eol = after.find ("\n", found + 1);
|
||||||
if (eol != std::string::npos)
|
if (eol != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string value = trim (after.substr (
|
std::string value = trim (after.substr (
|
||||||
found,
|
found,
|
||||||
eol - found), "\t ");
|
eol - found), "\t ");
|
||||||
|
|
||||||
std::string::size_type gap = value.find (" -- ");
|
auto gap = value.find (" -- ");
|
||||||
if (gap != std::string::npos)
|
if (gap != std::string::npos)
|
||||||
{
|
{
|
||||||
// TODO keeping the initial dates even if dateformat approximates them
|
// TODO keeping the initial dates even if dateformat approximates them
|
||||||
|
@ -714,7 +714,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||||
std::vector <std::string> orphanValues = findValues (after, "\n UDA Orphan ");
|
std::vector <std::string> orphanValues = findValues (after, "\n UDA Orphan ");
|
||||||
for (auto& orphan : orphanValues)
|
for (auto& orphan : orphanValues)
|
||||||
{
|
{
|
||||||
std::string::size_type colon = orphan.find (':');
|
auto colon = orphan.find (':');
|
||||||
if (colon != std::string::npos)
|
if (colon != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string name = trim (orphan.substr (0, colon), "\t ");
|
std::string name = trim (orphan.substr (0, colon), "\t ");
|
||||||
|
|
|
@ -426,7 +426,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
if (var.first.substr (0, 13) == "urgency.user.")
|
if (var.first.substr (0, 13) == "urgency.user.")
|
||||||
{
|
{
|
||||||
// urgency.user.project.<project>.coefficient
|
// urgency.user.project.<project>.coefficient
|
||||||
std::string::size_type end = std::string::npos;
|
auto end = std::string::npos;
|
||||||
if (var.first.substr (13, 8) == "project." &&
|
if (var.first.substr (13, 8) == "project." &&
|
||||||
(end = var.first.find (".coefficient")) != std::string::npos)
|
(end = var.first.find (".coefficient")) != std::string::npos)
|
||||||
{
|
{
|
||||||
|
@ -459,11 +459,11 @@ int CmdInfo::execute (std::string& output)
|
||||||
{
|
{
|
||||||
// urgency.uda.<name>.coefficient
|
// urgency.uda.<name>.coefficient
|
||||||
// urgency.uda.<name>.<value>.coefficient
|
// urgency.uda.<name>.<value>.coefficient
|
||||||
std::string::size_type end = var.first.find (".coefficient");
|
auto end = var.first.find (".coefficient");
|
||||||
if (end != std::string::npos)
|
if (end != std::string::npos)
|
||||||
{
|
{
|
||||||
const std::string uda = var.first.substr (12, end - 12);
|
const std::string uda = var.first.substr (12, end - 12);
|
||||||
std::string::size_type dot = uda.find (".");
|
auto dot = uda.find (".");
|
||||||
if (dot == std::string::npos)
|
if (dot == std::string::npos)
|
||||||
{
|
{
|
||||||
// urgency.uda.<name>.coefficient
|
// urgency.uda.<name>.coefficient
|
||||||
|
|
|
@ -56,7 +56,7 @@ int CmdReports::execute (std::string& output)
|
||||||
if (i.first.substr (0, 7) == "report.")
|
if (i.first.substr (0, 7) == "report.")
|
||||||
{
|
{
|
||||||
std::string report = i.first.substr (7);
|
std::string report = i.first.substr (7);
|
||||||
std::string::size_type columns = report.find (".columns");
|
auto columns = report.find (".columns");
|
||||||
if (columns != std::string::npos)
|
if (columns != std::string::npos)
|
||||||
reports.push_back (report.substr (0, columns));
|
reports.push_back (report.substr (0, columns));
|
||||||
}
|
}
|
||||||
|
|
|
@ -337,7 +337,7 @@ bool CmdSync::send (
|
||||||
{
|
{
|
||||||
// It is important that the ':' be the *last* colon, in order to support
|
// It is important that the ':' be the *last* colon, in order to support
|
||||||
// IPv6 addresses.
|
// IPv6 addresses.
|
||||||
std::string::size_type colon = to.rfind (':');
|
auto colon = to.rfind (':');
|
||||||
if (colon == std::string::npos)
|
if (colon == std::string::npos)
|
||||||
throw format (STRING_CMD_SYNC_BAD_SERVER, to);
|
throw format (STRING_CMD_SYNC_BAD_SERVER, to);
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ int CmdUDAs::execute (std::string& output)
|
||||||
if (name.first.substr (0, 4) == "uda." &&
|
if (name.first.substr (0, 4) == "uda." &&
|
||||||
name.first.find (".type") != std::string::npos)
|
name.first.find (".type") != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string::size_type period = name.first.find ('.', 4);
|
auto period = name.first.find ('.', 4);
|
||||||
if (period != std::string::npos)
|
if (period != std::string::npos)
|
||||||
udas.push_back (name.first.substr (4, period - 4));
|
udas.push_back (name.first.substr (4, period - 4));
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ int CmdCompletionUDAs::execute (std::string& output)
|
||||||
if (name.first.substr (0, 4) == "uda." &&
|
if (name.first.substr (0, 4) == "uda." &&
|
||||||
name.first.find (".type") != std::string::npos)
|
name.first.find (".type") != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string::size_type period = name.first.find ('.', 4);
|
auto period = name.first.find ('.', 4);
|
||||||
if (period != std::string::npos)
|
if (period != std::string::npos)
|
||||||
udas.push_back (name.first.substr (4, period - 4));
|
udas.push_back (name.first.substr (4, period - 4));
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ void Command::factory (std::map <std::string, Command*>& all)
|
||||||
if (i.first.substr (0, 7) == "report.")
|
if (i.first.substr (0, 7) == "report.")
|
||||||
{
|
{
|
||||||
std::string report = i.first.substr (7);
|
std::string report = i.first.substr (7);
|
||||||
std::string::size_type columns = report.find (".columns");
|
auto columns = report.find (".columns");
|
||||||
if (columns != std::string::npos)
|
if (columns != std::string::npos)
|
||||||
reports.push_back (report.substr (0, columns));
|
reports.push_back (report.substr (0, columns));
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,8 +392,8 @@ void UnitTest::is (
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void UnitTest::diag (const std::string& text)
|
void UnitTest::diag (const std::string& text)
|
||||||
{
|
{
|
||||||
std::string::size_type start = text.find_first_not_of (" \t\n\r\f");
|
auto start = text.find_first_not_of (" \t\n\r\f");
|
||||||
std::string::size_type end = text.find_last_not_of (" \t\n\r\f");
|
auto end = text.find_last_not_of (" \t\n\r\f");
|
||||||
std::cout << "# " << text.substr (start, end - start + 1) << "\n";
|
std::cout << "# " << text.substr (start, end - start + 1) << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue