mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
libhsared: migrating from local to libshared
This commit is contained in:
parent
456925a02b
commit
355620c640
88 changed files with 185 additions and 510 deletions
10
src/CLI2.cpp
10
src/CLI2.cpp
|
@ -32,8 +32,8 @@
|
|||
#include <Context.h>
|
||||
#include <Lexer.h>
|
||||
#include <Color.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
@ -1480,8 +1480,7 @@ void CLI2::findIDs ()
|
|||
else if (a._lextype == Lexer::Type::set)
|
||||
{
|
||||
// Split the ID list into elements.
|
||||
std::vector <std::string> elements;
|
||||
split (elements, a.attribute ("raw"), ',');
|
||||
auto elements = split (a.attribute ("raw"), ',');
|
||||
|
||||
for (auto& element : elements)
|
||||
{
|
||||
|
@ -1536,8 +1535,7 @@ void CLI2::findIDs ()
|
|||
a.tag ("FILTER");
|
||||
|
||||
// Split the ID list into elements.
|
||||
std::vector <std::string> elements;
|
||||
split (elements, raw, ',');
|
||||
auto elements = split (raw, ',');
|
||||
|
||||
for (const auto& element : elements)
|
||||
{
|
||||
|
|
|
@ -35,12 +35,16 @@ add_library (task CLI2.cpp CLI2.h
|
|||
text.cpp text.h
|
||||
util.cpp util.h)
|
||||
|
||||
add_library (libshared libshared/src/FS.cpp libshared/src/FS.h
|
||||
add_library (libshared libshared/src/Datetime.cpp libshared/src/Datetime.h
|
||||
libshared/src/Duration.cpp libshared/src/Duration.h
|
||||
libshared/src/FS.cpp libshared/src/FS.h
|
||||
libshared/src/JSON.cpp libshared/src/JSON.h
|
||||
libshared/src/Pig.cpp libshared/src/Pig.h
|
||||
libshared/src/RX.cpp libshared/src/RX.h
|
||||
libshared/src/Table.cpp libshared/src/Table.h
|
||||
libshared/src/Timer.cpp libshared/src/Timer.h
|
||||
libshared/src/shared.cpp libshared/src/shared.h
|
||||
libshared/src/format.cpp libshared/src/format.h
|
||||
libshared/src/unicode.cpp libshared/src/unicode.h
|
||||
libshared/src/utf8.cpp libshared/src/utf8.h
|
||||
libshared/src/wcwidth6.cpp)
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
#include <algorithm>
|
||||
#include <main.h>
|
||||
#include <Lexer.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
#include <string>
|
||||
|
||||
|
@ -130,8 +131,7 @@ Color::Color (const std::string& spec)
|
|||
: _value (0)
|
||||
{
|
||||
// Split spec into words.
|
||||
std::vector <std::string> words;
|
||||
split (words, spec, ' ');
|
||||
auto words = split (spec, ' ');
|
||||
|
||||
// Construct the color as two separate colors, then blend them later. This
|
||||
// make it possible to declare a color such as "color1 on black", and have
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include <JSON.h>
|
||||
#include <Lexer.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
#include <Eval.h>
|
||||
#include <Variant.h>
|
||||
#include <ISO8601.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <main.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
@ -576,7 +576,8 @@ bool Context::verbose (const std::string& token)
|
|||
if (verbosity.empty ())
|
||||
{
|
||||
verbosity_legacy = config.getBoolean ("verbose");
|
||||
split (verbosity, config.get ("verbose"), ',');
|
||||
for (auto& token : split (config.get ("verbose"), ','))
|
||||
verbosity.insert (token);
|
||||
|
||||
// Regular feedback means almost everything.
|
||||
// This odd test is to see if a Boolean-false value is a real one, which
|
||||
|
@ -700,8 +701,7 @@ void Context::staticInitialization ()
|
|||
rc.first.substr (rc.first.length () - 7, 7) == ".values")
|
||||
{
|
||||
std::string name = rc.first.substr (4, rc.first.length () - 7 - 4);
|
||||
std::vector <std::string> values;
|
||||
split (values, rc.second, ',');
|
||||
auto values = split (rc.second, ',');
|
||||
|
||||
for (auto r = values.rbegin(); r != values.rend (); ++r)
|
||||
Task::customOrder[name].push_back (*r);
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
#include <Variant.h>
|
||||
#include <Context.h>
|
||||
#include <ISO8601.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
@ -189,8 +190,7 @@ bool getDOM (const std::string& name, const Task& task, Variant& value)
|
|||
}
|
||||
|
||||
// split name on '.'
|
||||
std::vector <std::string> elements;
|
||||
split (elements, name, '.');
|
||||
auto elements = split (name, '.');
|
||||
|
||||
Task ref (task);
|
||||
Nibbler n (elements[0]);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <algorithm>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <ISO8601.h>
|
||||
#include <Lexer.h>
|
||||
#include <CLI2.h>
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
#include <Context.h>
|
||||
#include <Task.h>
|
||||
#include <Color.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
#include <Variant.h>
|
||||
#include <Dates.h>
|
||||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
|
|
|
@ -39,10 +39,12 @@
|
|||
#include <Context.h>
|
||||
#include <Variant.h>
|
||||
#include <DOM.h>
|
||||
#include <Lexer.h>
|
||||
#include <JSON.h>
|
||||
#include <Timer.h>
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
@ -468,7 +470,9 @@ void Hooks::assertSameTask (const std::vector <std::string>& input, const Task&
|
|||
}
|
||||
|
||||
json::string* up = (json::string*) u->second;
|
||||
std::string json_uuid = json::decode (unquoteText (up->dump ()));
|
||||
auto text = up->dump ();
|
||||
Lexer::dequote (text);
|
||||
std::string json_uuid = json::decode (text);
|
||||
if (json_uuid != uuid)
|
||||
{
|
||||
context.error (format (STRING_HOOK_ERROR_SAME2, uuid, json_uuid));
|
||||
|
@ -562,7 +566,7 @@ int Hooks::callHookScript (
|
|||
else
|
||||
status = execute (script, args, inputStr, outputStr);
|
||||
|
||||
split (output, outputStr, '\n');
|
||||
output = split (outputStr, '\n');
|
||||
|
||||
if (_debug >= 2)
|
||||
{
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
#ifdef PRODUCT_TASKWARRIOR
|
||||
#include <Dates.h>
|
||||
#endif
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <utf8.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
#include <Color.h>
|
||||
#include <ISO8601.h>
|
||||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <gnutls/x509.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
#define MAX_BUF 16384
|
||||
|
|
67
src/Task.cpp
67
src/Task.cpp
|
@ -45,7 +45,8 @@
|
|||
#ifdef PRODUCT_TASKWARRIOR
|
||||
#include <RX.h>
|
||||
#endif
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
|
||||
#include <i18n.h>
|
||||
|
@ -712,8 +713,7 @@ void Task::parseJSON (const json::object* root_obj)
|
|||
else if (i.first == "depends" && i.second->type() == json::j_string)
|
||||
{
|
||||
json::string* deps = (json::string*)i.second;
|
||||
std::vector <std::string> uuids;
|
||||
split (uuids, deps->_data, ',');
|
||||
auto uuids = split (deps->_data, ',');
|
||||
|
||||
for (const auto& uuid : uuids)
|
||||
addDependency (uuid);
|
||||
|
@ -721,11 +721,19 @@ void Task::parseJSON (const json::object* root_obj)
|
|||
|
||||
// Strings are decoded.
|
||||
else if (type == "string")
|
||||
set (i.first, json::decode (unquoteText (i.second->dump ())));
|
||||
{
|
||||
auto text = i.second->dump ();
|
||||
Lexer::dequote (text);
|
||||
set (i.first, json::decode (text));
|
||||
}
|
||||
|
||||
// Other types are simply added.
|
||||
else
|
||||
set (i.first, unquoteText (i.second->dump ()));
|
||||
{
|
||||
auto text = i.second->dump ();
|
||||
Lexer::dequote (text);
|
||||
set (i.first, text);
|
||||
}
|
||||
}
|
||||
|
||||
// UDA orphans and annotations do not have columns.
|
||||
|
@ -769,7 +777,9 @@ void Task::parseJSON (const json::object* root_obj)
|
|||
<< "' --> preserved\n";
|
||||
context.debug (message.str ());
|
||||
#endif
|
||||
set (i.first, json::decode (unquoteText (i.second->dump ())));
|
||||
auto text = i.second->dump ();
|
||||
Lexer::dequote (text);
|
||||
set (i.first, json::decode (text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -909,8 +919,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
|||
// Tags are converted to an array.
|
||||
else if (i.first == "tags")
|
||||
{
|
||||
std::vector <std::string> tags;
|
||||
split (tags, i.second, ',');
|
||||
auto tags = split (i.second, ',');
|
||||
|
||||
out << "\"tags\":[";
|
||||
|
||||
|
@ -949,8 +958,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
|||
#endif
|
||||
)
|
||||
{
|
||||
std::vector <std::string> deps;
|
||||
split (deps, i.second, ',');
|
||||
auto deps = split (i.second, ',');
|
||||
|
||||
out << "\"depends\":[";
|
||||
|
||||
|
@ -1148,16 +1156,13 @@ void Task::addDependency (const std::string& uuid)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::removeDependency (const std::string& uuid)
|
||||
{
|
||||
std::vector <std::string> deps;
|
||||
split (deps, get ("depends"), ',');
|
||||
auto deps = split (get ("depends"), ',');
|
||||
|
||||
auto i = std::find (deps.begin (), deps.end (), uuid);
|
||||
if (i != deps.end ())
|
||||
{
|
||||
deps.erase (i);
|
||||
std::string combined;
|
||||
join (combined, ",", deps);
|
||||
set ("depends", combined);
|
||||
set ("depends", join (",", deps));
|
||||
recalc_urgency = true;
|
||||
}
|
||||
else
|
||||
|
@ -1178,8 +1183,7 @@ void Task::removeDependency (int id)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::getDependencies (std::vector <int>& all) const
|
||||
{
|
||||
std::vector <std::string> deps;
|
||||
split (deps, get ("depends"), ',');
|
||||
auto deps = split (get ("depends"), ',');
|
||||
|
||||
all.clear ();
|
||||
|
||||
|
@ -1190,15 +1194,13 @@ void Task::getDependencies (std::vector <int>& all) const
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::getDependencies (std::vector <std::string>& all) const
|
||||
{
|
||||
all.clear ();
|
||||
split (all, get ("depends"), ',');
|
||||
all = split (get ("depends"), ',');
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::getDependencies (std::vector <Task>& all) const
|
||||
{
|
||||
std::vector <std::string> deps;
|
||||
split (deps, get ("depends"), ',');
|
||||
std::vector <std::string> deps = split (get ("depends"), ',');
|
||||
|
||||
all.clear ();
|
||||
|
||||
|
@ -1214,9 +1216,7 @@ void Task::getDependencies (std::vector <Task>& all) const
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Task::getTagCount () const
|
||||
{
|
||||
std::vector <std::string> tags;
|
||||
split (tags, get ("tags"), ',');
|
||||
|
||||
auto tags = split (get ("tags"), ',');
|
||||
return (int) tags.size ();
|
||||
}
|
||||
|
||||
|
@ -1275,8 +1275,7 @@ bool Task::hasTag (const std::string& tag) const
|
|||
}
|
||||
|
||||
// Concrete tags.
|
||||
std::vector <std::string> tags;
|
||||
split (tags, get ("tags"), ',');
|
||||
auto tags = split (get ("tags"), ',');
|
||||
|
||||
if (std::find (tags.begin (), tags.end (), tag) != tags.end ())
|
||||
return true;
|
||||
|
@ -1287,15 +1286,12 @@ bool Task::hasTag (const std::string& tag) const
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::addTag (const std::string& tag)
|
||||
{
|
||||
std::vector <std::string> tags;
|
||||
split (tags, get ("tags"), ',');
|
||||
auto tags = split (get ("tags"), ',');
|
||||
|
||||
if (std::find (tags.begin (), tags.end (), tag) == tags.end ())
|
||||
{
|
||||
tags.push_back (tag);
|
||||
std::string combined;
|
||||
join (combined, ",", tags);
|
||||
set ("tags", combined);
|
||||
set ("tags", join (",", tags));
|
||||
|
||||
recalc_urgency = true;
|
||||
}
|
||||
|
@ -1315,22 +1311,19 @@ void Task::addTags (const std::vector <std::string>& tags)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::getTags (std::vector<std::string>& tags) const
|
||||
{
|
||||
split (tags, get ("tags"), ',');
|
||||
tags = split (get ("tags"), ',');
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::removeTag (const std::string& tag)
|
||||
{
|
||||
std::vector <std::string> tags;
|
||||
split (tags, get ("tags"), ',');
|
||||
auto tags = split (get ("tags"), ',');
|
||||
|
||||
auto i = std::find (tags.begin (), tags.end (), tag);
|
||||
if (i != tags.end ())
|
||||
{
|
||||
tags.erase (i);
|
||||
std::string combined;
|
||||
join (combined, ",", tags);
|
||||
set ("tags", combined);
|
||||
set ("tags", join (",", tags));
|
||||
}
|
||||
|
||||
recalc_urgency = true;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <ISO8601.h>
|
||||
#include <Lexer.h>
|
||||
#include <RX.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <i18n.h>
|
||||
|
||||
std::string Variant::dateFormat = "";
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <ViewTask.h>
|
||||
#include <numeric>
|
||||
#include <Context.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <utf8.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <cmake.h>
|
||||
#include <ViewText.h>
|
||||
#include <Context.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <utf8.h>
|
||||
#include <main.h>
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
#include <ColDepends.h>
|
||||
#include <algorithm>
|
||||
#include <Context.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <utf8.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
|
@ -91,8 +92,7 @@ void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& ma
|
|||
for (auto& i : blocking)
|
||||
blocking_ids.push_back (i.id);
|
||||
|
||||
std::string all;
|
||||
join (all, " ", blocking_ids);
|
||||
auto all = join (" ", blocking_ids);
|
||||
maximum = all.length ();
|
||||
|
||||
unsigned int length;
|
||||
|
@ -134,8 +134,7 @@ void ColumnDepends::render (
|
|||
for (const auto& t : blocking)
|
||||
blocking_ids.push_back (t.id);
|
||||
|
||||
std::string combined;
|
||||
join (combined, " ", blocking_ids);
|
||||
auto combined = join (" ", blocking_ids);
|
||||
|
||||
std::vector <std::string> all;
|
||||
wrapText (all, combined, width, _hyphenate);
|
||||
|
@ -150,12 +149,8 @@ void ColumnDepends::render (
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnDepends::modify (Task& task, const std::string& value)
|
||||
{
|
||||
// Parse IDs
|
||||
std::vector <std::string> deps;
|
||||
split (deps, value, ',');
|
||||
|
||||
// Apply or remove dendencies in turn.
|
||||
for (auto& dep : deps)
|
||||
for (auto& dep : split (value, ','))
|
||||
{
|
||||
if (dep[0] == '-')
|
||||
{
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <Context.h>
|
||||
#include <ISO8601.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <utf8.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <cmake.h>
|
||||
#include <ColID.h>
|
||||
#include <math.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <cmake.h>
|
||||
#include <ColIMask.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <cmake.h>
|
||||
#include <ColMask.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <cmake.h>
|
||||
#include <ColParent.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
#include <Lexer.h>
|
||||
#include <Filter.h>
|
||||
#include <Dates.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <utf8.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
#include <Lexer.h>
|
||||
#include <Filter.h>
|
||||
#include <Dates.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <utf8.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <cmake.h>
|
||||
#include <ColStatus.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
#include <utf8.h>
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include <cmake.h>
|
||||
#include <ColString.h>
|
||||
#include <Context.h>
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
#include <Variant.h>
|
||||
#include <Filter.h>
|
||||
#include <Dates.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
#include <utf8.h>
|
||||
#include <main.h>
|
||||
|
@ -96,8 +97,7 @@ void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maxim
|
|||
// Find the widest tag.
|
||||
if (tags.find (',') != std::string::npos)
|
||||
{
|
||||
std::vector <std::string> all;
|
||||
split (all, tags, ',');
|
||||
auto all = split (tags, ',');
|
||||
for (const auto& tag : all)
|
||||
{
|
||||
auto length = utf8_width (tag);
|
||||
|
@ -132,10 +132,9 @@ void ColumnTags::render (
|
|||
{
|
||||
if (tags.find (',') != std::string::npos)
|
||||
{
|
||||
std::vector <std::string> all;
|
||||
split (all, tags, ',');
|
||||
auto all = split (tags, ',');
|
||||
std::sort (all.begin (), all.end ());
|
||||
join (tags, " ", all);
|
||||
tags = join (" ", all);
|
||||
|
||||
all.clear ();
|
||||
wrapText (all, tags, width, _hyphenate);
|
||||
|
@ -152,8 +151,7 @@ void ColumnTags::render (
|
|||
}
|
||||
else if (_style == "count")
|
||||
{
|
||||
std::vector <std::string> all;
|
||||
split (all, tags, ',');
|
||||
auto all = split (tags, ',');
|
||||
renderStringRight (lines, width, color, '[' + format (static_cast <int> (all.size ())) + ']');
|
||||
}
|
||||
}
|
||||
|
@ -167,10 +165,7 @@ void ColumnTags::modify (Task& task, const std::string& value)
|
|||
// TW-1701
|
||||
task.set ("tags", "");
|
||||
|
||||
std::vector <std::string> tags;
|
||||
split (tags, value, ',');
|
||||
|
||||
for (auto& tag : tags)
|
||||
for (auto& tag : split (value, ','))
|
||||
{
|
||||
// If it's a DOM ref, eval it first.
|
||||
Lexer lexer (tag);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <Variant.h>
|
||||
#include <Filter.h>
|
||||
#include <Dates.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <Variant.h>
|
||||
#include <Filter.h>
|
||||
#include <Dates.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <Variant.h>
|
||||
#include <Filter.h>
|
||||
#include <Dates.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <Variant.h>
|
||||
#include <Filter.h>
|
||||
#include <Dates.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
#include <ColUDA.h>
|
||||
#include <Context.h>
|
||||
#include <ISO8601.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <utf8.h>
|
||||
#include <i18n.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <cmake.h>
|
||||
#include <ColUUID.h>
|
||||
#include <math.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <cmake.h>
|
||||
#include <ColUrgency.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -51,7 +51,8 @@
|
|||
#include <ColUUID.h>
|
||||
#include <ColUDA.h>
|
||||
#include <ColWait.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
@ -186,7 +187,7 @@ Column* Column::uda (const std::string& name)
|
|||
c->_name = name;
|
||||
c->_label = label;
|
||||
if (values != "")
|
||||
split (c->_values, values, ',');
|
||||
c->_values = split (values, ',');
|
||||
return c;
|
||||
}
|
||||
else if (type == "numeric")
|
||||
|
@ -195,7 +196,7 @@ Column* Column::uda (const std::string& name)
|
|||
c->_name = name;
|
||||
c->_label = label;
|
||||
if (values != "")
|
||||
split (c->_values, values, ',');
|
||||
c->_values = split (values, ',');
|
||||
return c;
|
||||
}
|
||||
else if (type == "date")
|
||||
|
@ -204,7 +205,7 @@ Column* Column::uda (const std::string& name)
|
|||
c->_name = name;
|
||||
c->_label = label;
|
||||
if (values != "")
|
||||
split (c->_values, values, ',');
|
||||
c->_values = split (values, ',');
|
||||
return c;
|
||||
}
|
||||
else if (type == "duration")
|
||||
|
@ -213,7 +214,7 @@ Column* Column::uda (const std::string& name)
|
|||
c->_name = name;
|
||||
c->_label = label;
|
||||
if (values != "")
|
||||
split (c->_values, values, ',');
|
||||
c->_values = split (values, ',');
|
||||
return c;
|
||||
}
|
||||
else if (type != "")
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
#include <cmake.h>
|
||||
#include <CmdAdd.h>
|
||||
#include <Context.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
#include <util.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <util.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
|
||||
|
|
|
@ -33,8 +33,9 @@
|
|||
#include <ViewText.h>
|
||||
#include <Lexer.h>
|
||||
#include <i18n.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <utf8.h>
|
||||
#include <main.h>
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
#include <Context.h>
|
||||
#include <main.h>
|
||||
#include <Color.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <Context.h>
|
||||
#include <ViewText.h>
|
||||
#include <Color.h>
|
||||
#include <shared.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#include <Context.h>
|
||||
#include <JSON.h>
|
||||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <i18n.h>
|
||||
#include <util.h>
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
#include <text.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <CmdCount.h>
|
||||
#include <Filter.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <Lexer.h>
|
||||
#include <ViewTask.h>
|
||||
#include <i18n.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <main.h>
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <util.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <RX.h>
|
||||
#include <Context.h>
|
||||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#ifdef HAVE_COMMIT
|
||||
#include <commit.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <util.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <iostream>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
#include <Filter.h>
|
||||
#include <Pig.h>
|
||||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
|
@ -230,8 +231,7 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat)
|
|||
|
||||
std::vector <std::string> tags;
|
||||
task.getTags (tags);
|
||||
std::string allTags;
|
||||
join (allTags, " ", tags);
|
||||
auto allTags = join (" ", tags);
|
||||
|
||||
if (verbose)
|
||||
before << "# " << STRING_EDIT_TAG_SEP << '\n';
|
||||
|
@ -360,8 +360,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
|||
|
||||
// tags
|
||||
value = findValue (after, "\n Tags:");
|
||||
std::vector <std::string> tags;
|
||||
split (tags, value, ' ');
|
||||
auto tags = split (value, ' ');
|
||||
task.remove ("tags");
|
||||
task.addTags (tags);
|
||||
|
||||
|
@ -676,8 +675,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
|||
|
||||
// Dependencies
|
||||
value = findValue (after, "\n Dependencies:");
|
||||
std::vector <std::string> dependencies;
|
||||
split (dependencies, value, ",");
|
||||
auto dependencies = split (value, ',');
|
||||
|
||||
task.remove ("depends");
|
||||
for (auto& dep : dependencies)
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#include <Context.h>
|
||||
#include <DOM.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
@ -90,7 +91,7 @@ int CmdGet::execute (std::string& output)
|
|||
if (results.size () == 0)
|
||||
throw std::string (STRING_CMD_GET_NO_DOM);
|
||||
|
||||
join (output, " ", results);
|
||||
output = join (" ", results);
|
||||
output += '\n';
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#include <ViewText.h>
|
||||
#include <Context.h>
|
||||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <Filter.h>
|
||||
#include <ViewText.h>
|
||||
#include <main.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
#include <ISO8601.h>
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
@ -163,8 +163,7 @@ int CmdCompletionIds::execute (std::string& output)
|
|||
ids.push_back (task.id);
|
||||
|
||||
std::sort (ids.begin (), ids.end ());
|
||||
join (output, "\n", ids);
|
||||
output += '\n';
|
||||
output = join ("\n", ids) + '\n';
|
||||
|
||||
context.headers.clear ();
|
||||
return 0;
|
||||
|
@ -240,8 +239,7 @@ int CmdUUIDs::execute (std::string& output)
|
|||
uuids.push_back (task.get ("uuid"));
|
||||
|
||||
std::sort (uuids.begin (), uuids.end ());
|
||||
join (output, " ", uuids);
|
||||
output += '\n';
|
||||
output = join (" ", uuids) + '\n';
|
||||
|
||||
context.headers.clear ();
|
||||
return 0;
|
||||
|
@ -277,8 +275,7 @@ int CmdCompletionUuids::execute (std::string& output)
|
|||
uuids.push_back (task.get ("uuid"));
|
||||
|
||||
std::sort (uuids.begin (), uuids.end ());
|
||||
join (output, "\n", uuids);
|
||||
output += '\n';
|
||||
output = join ("\n", uuids) + '\n';
|
||||
|
||||
context.headers.clear ();
|
||||
return 0;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <sstream>
|
||||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <Filter.h>
|
||||
#include <ISO8601.h>
|
||||
#include <main.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <cmake.h>
|
||||
#include <CmdLog.h>
|
||||
#include <Context.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
#include <util.h>
|
||||
#include <main.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <util.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <ViewText.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <Filter.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <algorithm>
|
||||
#include <Context.h>
|
||||
#include <ViewText.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
#include <Context.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <main.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <Filter.h>
|
||||
#include <ViewText.h>
|
||||
#include <ISO8601.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <Color.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
@ -91,8 +92,7 @@ int CmdSync::execute (std::string& output)
|
|||
if (credentials_string == "")
|
||||
throw std::string (STRING_CMD_SYNC_BAD_CRED);
|
||||
|
||||
std::vector <std::string> credentials;
|
||||
split (credentials, credentials_string, "/");
|
||||
auto credentials = split (credentials_string, '/');
|
||||
if (credentials.size () != 3)
|
||||
throw std::string (STRING_CMD_SYNC_BAD_CRED);
|
||||
|
||||
|
@ -198,8 +198,7 @@ int CmdSync::execute (std::string& output)
|
|||
|
||||
int download_count = 0;
|
||||
payload = response.getPayload ();
|
||||
std::vector <std::string> lines;
|
||||
split (lines, payload, '\n');
|
||||
auto lines = split (payload, '\n');
|
||||
|
||||
// Load all tasks, but only if necessary. There is always a sync key in
|
||||
// the payload, so if there are two or more lines, then we have merging
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <ViewText.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <ISO8601.h>
|
||||
#include <main.h>
|
||||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <main.h>
|
||||
#include <format.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <Context.h>
|
||||
#include <Filter.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <Filter.h>
|
||||
#include <Lexer.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#ifdef HAVE_COMMIT
|
||||
#include <commit.h>
|
||||
#endif
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
#include <Command.h>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <Context.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
#include <ISO8601.h>
|
||||
#include <Lexer.h>
|
||||
#include <main.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
@ -52,10 +52,7 @@ std::string taskIdentifiers (const std::vector <Task>& tasks)
|
|||
for (auto task: tasks)
|
||||
identifiers.push_back (task.identifier (true));
|
||||
|
||||
std::string result;
|
||||
join (result, ", ", identifiers);
|
||||
|
||||
return result;
|
||||
return join (", ", identifiers);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <cstddef>
|
||||
#include <sstream>
|
||||
#include <Context.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
16
src/main.h
16
src/main.h
|
@ -83,21 +83,5 @@ std::string legacyCheckForDeprecatedVariables ();
|
|||
std::string legacyCheckForDeprecatedColumns ();
|
||||
void legacyAttributeMap (std::string&);
|
||||
|
||||
// list template
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <class T> void listDiff (
|
||||
const T& left, const T& right, T& leftOnly, T& rightOnly)
|
||||
{
|
||||
leftOnly.clear ();
|
||||
for (auto& l : left)
|
||||
if (std::find (right.begin (), right.end (), l) == right.end ())
|
||||
leftOnly.push_back (l);
|
||||
|
||||
rightOnly.clear ();
|
||||
for (auto& r : right)
|
||||
if (std::find (left.begin (), left.end (), r) == left.end ())
|
||||
rightOnly.push_back (r);
|
||||
}
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <Context.h>
|
||||
#include <Lexer.h>
|
||||
#include <ISO8601.h>
|
||||
#include <text.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
#include <main.h>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <Context.h>
|
||||
#include <ISO8601.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <shared.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
#include <Context.h>
|
||||
#include <ISO8601.h>
|
||||
#include <Task.h>
|
||||
#include <text.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
@ -52,8 +53,7 @@ void sort_tasks (
|
|||
global_data = &data;
|
||||
|
||||
// Split the key defs.
|
||||
global_keys.clear ();
|
||||
split (global_keys, keys, ',');
|
||||
global_keys = split (keys, ',');
|
||||
|
||||
// Only sort if necessary.
|
||||
if (order.size ())
|
||||
|
|
242
src/text.cpp
242
src/text.cpp
|
@ -170,33 +170,6 @@ std::string unquoteText (const std::string& input)
|
|||
return output;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int longestWord (const std::string& input)
|
||||
{
|
||||
int longest = 0;
|
||||
int length = 0;
|
||||
std::string::size_type i = 0;
|
||||
int character;
|
||||
|
||||
while ((character = utf8_next_char (input, i)))
|
||||
{
|
||||
if (character == ' ')
|
||||
{
|
||||
if (length > longest)
|
||||
longest = length;
|
||||
|
||||
length = 0;
|
||||
}
|
||||
else
|
||||
length += mk_wcwidth (character);
|
||||
}
|
||||
|
||||
if (length > longest)
|
||||
longest = length;
|
||||
|
||||
return longest;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int longestLine (const std::string& input)
|
||||
{
|
||||
|
@ -312,32 +285,6 @@ bool extractLine (
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string str_replace (
|
||||
std::string &str,
|
||||
const std::string& search,
|
||||
const std::string& replacement)
|
||||
{
|
||||
std::string::size_type pos = 0;
|
||||
while ((pos = str.find (search, pos)) != std::string::npos)
|
||||
{
|
||||
str.replace (pos, search.length (), replacement);
|
||||
pos += replacement.length ();
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string str_replace (
|
||||
const std::string& str,
|
||||
const std::string& search,
|
||||
const std::string& replacement)
|
||||
{
|
||||
std::string modified = str;
|
||||
return str_replace (modified, search, replacement);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const char* optionalBlankLine ()
|
||||
{
|
||||
|
@ -356,127 +303,6 @@ bool nontrivial (const std::string& input)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool compare (
|
||||
const std::string& left,
|
||||
const std::string& right,
|
||||
bool sensitive /*= true*/)
|
||||
{
|
||||
// Use strcasecmp if required.
|
||||
if (!sensitive)
|
||||
return strcasecmp (left.c_str (), right.c_str ()) == 0 ? true : false;
|
||||
|
||||
// Otherwise, just use std::string::operator==.
|
||||
return left == right;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool closeEnough (
|
||||
const std::string& reference,
|
||||
const std::string& attempt,
|
||||
unsigned int minLength /* = 0 */)
|
||||
{
|
||||
// An exact match is accepted first.
|
||||
if (compare (reference, attempt, false))
|
||||
return true;
|
||||
|
||||
// A partial match will suffice.
|
||||
if (attempt.length () < reference.length () &&
|
||||
attempt.length () >= minLength)
|
||||
return compare (reference.substr (0, attempt.length ()), attempt, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string::size_type find (
|
||||
const std::string& text,
|
||||
const std::string& pattern,
|
||||
bool sensitive /*= true*/)
|
||||
{
|
||||
// Implement a sensitive find, which is really just a loop withing a loop,
|
||||
// comparing lower-case versions of each character in turn.
|
||||
if (!sensitive)
|
||||
{
|
||||
// Handle empty pattern.
|
||||
const char* p = pattern.c_str ();
|
||||
size_t len = pattern.length ();
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
// Evaluate these once, for performance reasons.
|
||||
const char* t = text.c_str ();
|
||||
const char* start = t;
|
||||
const char* end = start + text.size ();
|
||||
|
||||
for (; t <= end - len; ++t)
|
||||
{
|
||||
int diff = 0;
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
if ((diff = tolower (t[i]) - tolower (p[i])))
|
||||
break;
|
||||
|
||||
// diff == 0 means there was no break from the loop, which only occurs
|
||||
// when a difference is detected. Therefore, the loop terminated, and
|
||||
// diff is zero.
|
||||
if (diff == 0)
|
||||
return t - start;
|
||||
}
|
||||
|
||||
return std::string::npos;
|
||||
}
|
||||
|
||||
// Otherwise, just use std::string::find.
|
||||
return text.find (pattern);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string::size_type find (
|
||||
const std::string& text,
|
||||
const std::string& pattern,
|
||||
std::string::size_type begin,
|
||||
bool sensitive /*= true*/)
|
||||
{
|
||||
// Implement a sensitive find, which is really just a loop withing a loop,
|
||||
// comparing lower-case versions of each character in turn.
|
||||
if (!sensitive)
|
||||
{
|
||||
// Handle empty pattern.
|
||||
const char* p = pattern.c_str ();
|
||||
size_t len = pattern.length ();
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
// Handle bad begin.
|
||||
if (begin >= text.length ())
|
||||
return std::string::npos;
|
||||
|
||||
// Evaluate these once, for performance reasons.
|
||||
const char* start = text.c_str ();
|
||||
const char* t = start + begin;
|
||||
const char* end = start + text.size ();
|
||||
|
||||
for (; t <= end - len; ++t)
|
||||
{
|
||||
int diff = 0;
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
if ((diff = tolower (t[i]) - tolower (p[i])))
|
||||
break;
|
||||
|
||||
// diff == 0 means there was no break from the loop, which only occurs
|
||||
// when a difference is detected. Therefore, the loop terminated, and
|
||||
// diff is zero.
|
||||
if (diff == 0)
|
||||
return t - start;
|
||||
}
|
||||
|
||||
return std::string::npos;
|
||||
}
|
||||
|
||||
// Otherwise, just use std::string::find.
|
||||
return text.find (pattern, begin);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Return the length, in characters, of the input, subtracting color control
|
||||
// codes.
|
||||
|
@ -536,74 +362,6 @@ const std::string obfuscateText (const std::string& input)
|
|||
return output.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string format (std::string& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string format (const char* value)
|
||||
{
|
||||
std::string s (value);
|
||||
return s;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string formatHex (int value)
|
||||
{
|
||||
std::stringstream s;
|
||||
s.setf (std::ios::hex, std::ios::basefield);
|
||||
s << value;
|
||||
return s.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string format (float value, int width, int precision)
|
||||
{
|
||||
std::stringstream s;
|
||||
s.width (width);
|
||||
s.precision (precision);
|
||||
if (0 < value && value < 1)
|
||||
{
|
||||
// For value close to zero, width - 2 (2 accounts for the first zero and
|
||||
// the dot) is the number of digits after zero that are significant
|
||||
double factor = 1;
|
||||
for (int i = 2; i < width; i++)
|
||||
factor *= 10;
|
||||
value = roundf (value * factor) / factor;
|
||||
}
|
||||
s << value;
|
||||
return s.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string format (double value, int width, int precision)
|
||||
{
|
||||
std::stringstream s;
|
||||
s.width (width);
|
||||
s.precision (precision);
|
||||
if (0 < value && value < 1)
|
||||
{
|
||||
// For value close to zero, width - 2 (2 accounts for the first zero and
|
||||
// the dot) is the number of digits after zero that are significant
|
||||
double factor = 1;
|
||||
for (int i = 2; i < width; i++)
|
||||
factor *= 10;
|
||||
value = round (value * factor) / factor;
|
||||
}
|
||||
s << value;
|
||||
return s.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string format (double value)
|
||||
{
|
||||
std::stringstream s;
|
||||
s << std::fixed << value;
|
||||
return s.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void replace_positional (
|
||||
std::string& fmt,
|
||||
|
|
42
src/text.h
42
src/text.h
|
@ -35,7 +35,6 @@
|
|||
// text.cpp, Non-UTF-8 aware.
|
||||
void wrapText (std::vector <std::string>&, const std::string&, const int, bool);
|
||||
std::string unquoteText (const std::string&);
|
||||
int longestWord (const std::string&);
|
||||
int longestLine (const std::string&);
|
||||
bool extractLine (std::string&, const std::string&, int, bool, unsigned int&);
|
||||
void split (std::set<std::string>&, const std::string&, const char);
|
||||
|
@ -43,53 +42,12 @@ void split (std::vector<std::string>&, const std::string&, const char);
|
|||
void split (std::vector<std::string>&, const std::string&, const std::string&);
|
||||
void join (std::string&, const std::string&, const std::vector<std::string>&);
|
||||
void join (std::string&, const std::string&, const std::vector<int>&);
|
||||
const std::string str_replace (std::string&, const std::string&, const std::string&);
|
||||
const std::string str_replace (const std::string&, const std::string&, const std::string&);
|
||||
const char* optionalBlankLine ();
|
||||
bool nontrivial (const std::string&);
|
||||
bool compare (const std::string&, const std::string&, bool sensitive = true);
|
||||
bool closeEnough (const std::string&, const std::string&, unsigned int minLength = 0);
|
||||
std::string::size_type find (const std::string&, const std::string&, bool sensitive = true);
|
||||
std::string::size_type find (const std::string&, const std::string&, std::string::size_type, bool sensitive = true);
|
||||
int strippedLength (const std::string&);
|
||||
const std::string obfuscateText (const std::string&);
|
||||
const std::string format (std::string&);
|
||||
const std::string format (const char*);
|
||||
const std::string formatHex (int);
|
||||
const std::string format (float, int, int);
|
||||
const std::string format (double, int, int);
|
||||
const std::string format (double);
|
||||
void replace_positional (std::string&, const std::string&, const std::string&);
|
||||
|
||||
template<typename T>
|
||||
const std::string format (T value)
|
||||
{
|
||||
std::stringstream s;
|
||||
s << value;
|
||||
return s.str ();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const std::string format (int fmt_num, const std::string& fmt, T arg)
|
||||
{
|
||||
std::string output = fmt;
|
||||
replace_positional (output, '{' + format (fmt_num) + '}', format (arg));
|
||||
return output;
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
const std::string format (int fmt_num, const std::string& fmt, T arg, Args... args)
|
||||
{
|
||||
const std::string fmt_replaced (format (fmt_num, fmt, arg));
|
||||
return format (fmt_num+1, fmt_replaced, args...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
const std::string format (const std::string& fmt, Args... args)
|
||||
{
|
||||
return format (1, fmt, args...);
|
||||
}
|
||||
|
||||
std::string leftJustify (const int, const int);
|
||||
std::string leftJustify (const std::string&, const int);
|
||||
std::string rightJustifyZero (const int, const int);
|
||||
|
|
37
src/util.cpp
37
src/util.cpp
|
@ -25,7 +25,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <util.h>
|
||||
#include <shared.h>
|
||||
// If <iostream> is included, put it after <stdio.h>, because it includes
|
||||
// <stdio.h>, and therefore would ignore the _WITH_GETLINE.
|
||||
#ifdef FREEBSD
|
||||
|
@ -163,41 +163,6 @@ std::string formatBytes (size_t bytes)
|
|||
return Lexer::commify (formatted);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int autoComplete (
|
||||
const std::string& partial,
|
||||
const std::vector<std::string>& list,
|
||||
std::vector<std::string>& matches,
|
||||
int minimum/* = 1*/)
|
||||
{
|
||||
matches.clear ();
|
||||
|
||||
// Handle trivial case.
|
||||
unsigned int length = partial.length ();
|
||||
if (length)
|
||||
{
|
||||
for (auto& item : list)
|
||||
{
|
||||
// An exact match is a special case. Assume there is only one exact match
|
||||
// and return immediately.
|
||||
if (partial == item)
|
||||
{
|
||||
matches.clear ();
|
||||
matches.push_back (item);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Maintain a list of partial matches.
|
||||
else if (length >= (unsigned) minimum &&
|
||||
length <= item.length () &&
|
||||
partial == item.substr (0, length))
|
||||
matches.push_back (item);
|
||||
}
|
||||
}
|
||||
|
||||
return matches.size ();
|
||||
}
|
||||
|
||||
// Handle the generation of UUIDs on FreeBSD in a separate implementation
|
||||
// of the uuid () function, since the API is quite different from Linux's.
|
||||
// Also, uuid_unparse_lower is not needed on FreeBSD, because the string
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
bool confirm (const std::string&);
|
||||
int confirm4 (const std::string&);
|
||||
std::string formatBytes (size_t);
|
||||
int autoComplete (const std::string&, const std::vector<std::string>&, std::vector<std::string>&, int minimum = 1);
|
||||
|
||||
#ifndef HAVE_UUID_UNPARSE_LOWER
|
||||
void uuid_unparse_lower (uuid_t uu, char *out);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue