diff --git a/src/Context.cpp b/src/Context.cpp index 7ae4315d5..8c69eb637 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -534,13 +534,8 @@ bool Context::verbose (const std::string& token) verbosity[0] != "sync" && // verbosity[0] != "filter") // { - verbosity.clear (); - // This list emulates rc.verbose=off in version 1.9.4. - verbosity.push_back ("blank"); - verbosity.push_back ("label"); - verbosity.push_back ("new-id"); - verbosity.push_back ("edit"); + verbosity = {"blank", "label", "new-id", "edit"}; } } @@ -765,8 +760,7 @@ void Context::updateVerbosity () if (command != "" && command[0] == '_') { - verbosity.clear (); - verbosity.push_back ("nothing"); + verbosity = {"nothing"}; } } diff --git a/src/DOM.cpp b/src/DOM.cpp index 531443a9f..cf4ce6452 100644 --- a/src/DOM.cpp +++ b/src/DOM.cpp @@ -52,16 +52,12 @@ DOM::~DOM () //////////////////////////////////////////////////////////////////////////////// const std::vector DOM::get_references () const { - std::vector refs; - - refs.push_back ("context.program"); - refs.push_back ("context.args"); - refs.push_back ("context.width"); - refs.push_back ("context.height"); - refs.push_back ("system.version"); - refs.push_back ("system.os"); - - return refs; + return {"context.program", + "context.args", + "context.width", + "context.height", + "system.version", + "system.os"}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColDate.cpp b/src/columns/ColDate.cpp index a150819c0..f7aa6aea6 100644 --- a/src/columns/ColDate.cpp +++ b/src/columns/ColDate.cpp @@ -43,23 +43,23 @@ ColumnDate::ColumnDate () _style = "formatted"; _label = ""; - _styles.push_back ("formatted"); - _styles.push_back ("julian"); - _styles.push_back ("epoch"); - _styles.push_back ("iso"); - _styles.push_back ("age"); - _styles.push_back ("remaining"); - _styles.push_back ("countdown"); + _styles = {"formatted", + "julian", + "epoch", + "iso", + "age", + "remaining", + "countdown"}; Date now; now -= 125; // So that "age" is non-zero. - _examples.push_back (now.toString (context.config.get ("dateformat"))); - _examples.push_back (format (now.toJulian (), 13, 12)); - _examples.push_back (now.toEpochString ()); - _examples.push_back (now.toISO ()); - _examples.push_back (Duration (Date () - now).formatCompact ()); - _examples.push_back (""); - _examples.push_back (Duration (Date () - now).format ()); + _examples = {now.toString (context.config.get ("dateformat")), + format (now.toJulian (), 13, 12), + now.toEpochString (), + now.toISO (), + Duration (Date () - now).formatCompact (), + "", + Duration (Date () - now).format ()}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColDepends.cpp b/src/columns/ColDepends.cpp index 73b390851..be6d7d8e8 100644 --- a/src/columns/ColDepends.cpp +++ b/src/columns/ColDepends.cpp @@ -43,13 +43,13 @@ ColumnDepends::ColumnDepends () _style = "list"; _label = STRING_COLUMN_LABEL_DEP; - _styles.push_back ("list"); - _styles.push_back ("count"); - _styles.push_back ("indicator"); + _styles = {"list", + "count", + "indicator"}; - _examples.push_back ("1 2 10"); - _examples.push_back ("[3]"); - _examples.push_back (context.config.get ("dependency.indicator")); + _examples = {"1 2 10", + "[3]", + context.config.get ("dependency.indicator")}; _hyphenate = context.config.getBoolean ("hyphenate"); } diff --git a/src/columns/ColDescription.cpp b/src/columns/ColDescription.cpp index aa0801c29..3e197917d 100644 --- a/src/columns/ColDescription.cpp +++ b/src/columns/ColDescription.cpp @@ -44,12 +44,12 @@ ColumnDescription::ColumnDescription () _style = "combined"; _label = STRING_COLUMN_LABEL_DESC; - _styles.push_back ("combined"); - _styles.push_back ("desc"); - _styles.push_back ("oneline"); - _styles.push_back ("truncated"); - _styles.push_back ("count"); - _styles.push_back ("truncated_count"); + _styles = {"combined", + "desc", + "oneline", + "truncated", + "count", + "truncated_count"}; _dateformat = context.config.get ("dateformat.annotation"); if (_dateformat == "") @@ -62,20 +62,18 @@ ColumnDescription::ColumnDescription () std::string a3 = STRING_COLUMN_EXAMPLES_ANNO3; std::string a4 = STRING_COLUMN_EXAMPLES_ANNO4; - _examples.push_back (d - + "\n " + t + " " + a1 - + "\n " + t + " " + a2 - + "\n " + t + " " + a3 - + "\n " + t + " " + a4); - _examples.push_back (d); - _examples.push_back (d - + " " + t + " " + a1 - + " " + t + " " + a2 - + " " + t + " " + a3 - + " " + t + " " + a4); - _examples.push_back (d.substr (0, 20) + "..."); - _examples.push_back (d + " [4]"); - _examples.push_back (d.substr (0, 20) + "... [4]"); + _examples = {d + "\n " + t + " " + a1 + + "\n " + t + " " + a2 + + "\n " + t + " " + a3 + + "\n " + t + " " + a4, + d, + d + " " + t + " " + a1 + + " " + t + " " + a2 + + " " + t + " " + a3 + + " " + t + " " + a4, + d.substr (0, 20) + "...", + d + " [4]", + d.substr (0, 20) + "... [4]"}; _hyphenate = context.config.getBoolean ("hyphenate"); diff --git a/src/columns/ColDue.cpp b/src/columns/ColDue.cpp index 3dc29952c..ce62a8694 100644 --- a/src/columns/ColDue.cpp +++ b/src/columns/ColDue.cpp @@ -43,7 +43,7 @@ ColumnDue::ColumnDue () Date now; now += 125; - _examples.push_back (Duration (now - Date ()).formatCompact ()); + _examples = {Duration (now - Date ()).formatCompact ()}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColID.cpp b/src/columns/ColID.cpp index ddcec616c..2c07106ff 100644 --- a/src/columns/ColID.cpp +++ b/src/columns/ColID.cpp @@ -41,10 +41,8 @@ ColumnID::ColumnID () _style = "number"; _label = STRING_COLUMN_LABEL_ID; _modifiable = false; - - _styles.push_back ("number"); - - _examples.push_back ("123"); + _styles = {"number"}; + _examples = {"123"}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColIMask.cpp b/src/columns/ColIMask.cpp index 880b3c22c..623566552 100644 --- a/src/columns/ColIMask.cpp +++ b/src/columns/ColIMask.cpp @@ -41,10 +41,8 @@ ColumnIMask::ColumnIMask () _style = "number"; _label = STRING_COLUMN_LABEL_MASK_IDX; _modifiable = false; - - _styles.push_back ("number"); - - _examples.push_back ("12"); + _styles = {"number"}; + _examples = {"12"}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColMask.cpp b/src/columns/ColMask.cpp index dbb5af298..b0e8c893f 100644 --- a/src/columns/ColMask.cpp +++ b/src/columns/ColMask.cpp @@ -41,10 +41,8 @@ ColumnMask::ColumnMask () _style = "default"; _label = STRING_COLUMN_LABEL_MASK; _modifiable = false; - - _styles.push_back ("default"); - - _examples.push_back ("++++---"); + _styles = {"default"}; + _examples = {"++++---"}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColParent.cpp b/src/columns/ColParent.cpp index efc21582d..1d1d0eac3 100644 --- a/src/columns/ColParent.cpp +++ b/src/columns/ColParent.cpp @@ -41,12 +41,8 @@ ColumnParent::ColumnParent () _style = "long"; _label = STRING_COLUMN_LABEL_PARENT; _modifiable = false; - - _styles.push_back ("long"); - _styles.push_back ("short"); - - _examples.push_back ("f30cb9c3-3fc0-483f-bfb2-3bf134f00694"); - _examples.push_back ("34f00694"); + _styles = {"long", "short"}; + _examples = {"f30cb9c3-3fc0-483f-bfb2-3bf134f00694", "34f00694"}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColProject.cpp b/src/columns/ColProject.cpp index 25371cb5c..8cca278f5 100644 --- a/src/columns/ColProject.cpp +++ b/src/columns/ColProject.cpp @@ -37,19 +37,14 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnProject::ColumnProject () { - _name = "project"; - _type = "string"; - _style = "full"; - _label = STRING_COLUMN_LABEL_PROJECT; - - _styles.push_back ("full"); - _styles.push_back ("parent"); - _styles.push_back ("indented"); - - _examples.push_back (STRING_COLUMN_EXAMPLES_PROJ); - _examples.push_back (STRING_COLUMN_EXAMPLES_PAR); - _examples.push_back (STRING_COLUMN_EXAMPLES_IND); - + _name = "project"; + _type = "string"; + _style = "full"; + _label = STRING_COLUMN_LABEL_PROJECT; + _styles = {"full", "parent", "indented"}; + _examples = {STRING_COLUMN_EXAMPLES_PROJ, + STRING_COLUMN_EXAMPLES_PAR, + STRING_COLUMN_EXAMPLES_IND}; _hyphenate = context.config.getBoolean ("hyphenate"); } diff --git a/src/columns/ColRecur.cpp b/src/columns/ColRecur.cpp index 73436d9c0..9f1534e49 100644 --- a/src/columns/ColRecur.cpp +++ b/src/columns/ColRecur.cpp @@ -37,20 +37,16 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnRecur::ColumnRecur () { - _name = "recur"; + _name = "recur"; // This is 'string', and not 'duration' to force the value to be stored as a // raw duration, so that it can be reevaluated every time. - _type = "string"; + _type = "string"; - _style = "duration"; - _label = STRING_COLUMN_LABEL_RECUR; - - _styles.push_back ("duration"); - _styles.push_back ("indicator"); - - _examples.push_back ("weekly"); - _examples.push_back (context.config.get ("recurrence.indicator")); + _style = "duration"; + _label = STRING_COLUMN_LABEL_RECUR; + _styles = {"duration", "indicator"}; + _examples = {"weekly", context.config.get ("recurrence.indicator")}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColScheduled.cpp b/src/columns/ColScheduled.cpp index a90785e68..55d42c523 100644 --- a/src/columns/ColScheduled.cpp +++ b/src/columns/ColScheduled.cpp @@ -38,14 +38,13 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnScheduled::ColumnScheduled () { - _name = "scheduled"; - _label = STRING_COLUMN_LABEL_SCHED; - - _styles.push_back ("countdown"); + _name = "scheduled"; + _label = STRING_COLUMN_LABEL_SCHED; + _styles = {"countdown"}; Date now; now += 125; - _examples.push_back (Duration (now - Date ()).formatCompact ()); + _examples = {Duration (now - Date ()).formatCompact ()}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColStart.cpp b/src/columns/ColStart.cpp index ce0ea2fb1..1bb070d74 100644 --- a/src/columns/ColStart.cpp +++ b/src/columns/ColStart.cpp @@ -36,12 +36,10 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnStart::ColumnStart () { - _name = "start"; - _label = STRING_COLUMN_LABEL_STARTED; - - _styles.push_back ("active"); - - _examples.push_back (context.config.get ("active.indicator")); + _name = "start"; + _label = STRING_COLUMN_LABEL_STARTED; + _styles = {"active"}; + _examples = {context.config.get ("active.indicator")}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColStatus.cpp b/src/columns/ColStatus.cpp index f8ea3ed43..01a8d4f52 100644 --- a/src/columns/ColStatus.cpp +++ b/src/columns/ColStatus.cpp @@ -36,16 +36,13 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnStatus::ColumnStatus () { - _name = "status"; - _type = "string"; - _style = "long"; - _label = STRING_COLUMN_LABEL_STATUS; - - _styles.push_back ("long"); - _styles.push_back ("short"); - - _examples.push_back (STRING_COLUMN_LABEL_STAT_PE); - _examples.push_back (STRING_COLUMN_LABEL_STAT_P); + _name = "status"; + _type = "string"; + _style = "long"; + _label = STRING_COLUMN_LABEL_STATUS; + _styles = {"long", "short"}; + _examples = {STRING_COLUMN_LABEL_STAT_PE, + STRING_COLUMN_LABEL_STAT_P}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColString.cpp b/src/columns/ColString.cpp index df825633e..499448989 100644 --- a/src/columns/ColString.cpp +++ b/src/columns/ColString.cpp @@ -35,21 +35,18 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnString::ColumnString () { - _name = "string"; - _type = "string"; - _style = "left"; - _label = ""; - - _styles.push_back ("left"); - _styles.push_back ("right"); - _styles.push_back ("left_fixed"); - _styles.push_back ("right_fixed"); - - _styles.push_back ("Hello (wrapped) "); - _styles.push_back (" Hello (wrapped)"); - _styles.push_back ("Hello (no-wrap) "); - _styles.push_back (" Hello (no-wrap)"); - + _name = "string"; + _type = "string"; + _style = "left"; + _label = ""; + _styles = {"left", + "right", + "left_fixed", + "right_fixed"}; + _examples = {"Hello (wrapped) ", + " Hello (wrapped)", + "Hello (no-wrap) ", + " Hello (no-wrap)"}; _hyphenate = context.config.getBoolean ("hyphenate"); } diff --git a/src/columns/ColTags.cpp b/src/columns/ColTags.cpp index 9e64d7f18..311bbf33f 100644 --- a/src/columns/ColTags.cpp +++ b/src/columns/ColTags.cpp @@ -37,19 +37,14 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnTags::ColumnTags () { - _name = "tags"; - _type = "string"; - _style = "list"; - _label = STRING_COLUMN_LABEL_TAGS; - - _styles.push_back ("list"); - _styles.push_back ("indicator"); - _styles.push_back ("count"); - - _examples.push_back (STRING_COLUMN_EXAMPLES_TAGS); - _examples.push_back (context.config.get ("tag.indicator")); - _examples.push_back ("[2]"); - + _name = "tags"; + _type = "string"; + _style = "list"; + _label = STRING_COLUMN_LABEL_TAGS; + _styles = {"list", "indicator", "count"}; + _examples = {STRING_COLUMN_EXAMPLES_TAGS, + context.config.get ("tag.indicator"), + "[2]"}; _hyphenate = context.config.getBoolean ("hyphenate"); } diff --git a/src/columns/ColUDA.cpp b/src/columns/ColUDA.cpp index 8a72ccb29..d38d1758f 100644 --- a/src/columns/ColUDA.cpp +++ b/src/columns/ColUDA.cpp @@ -39,16 +39,13 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnUDA::ColumnUDA () { - _name = ""; - _type = "string"; - _style = "default"; - _label = ""; - _uda = true; - + _name = ""; + _type = "string"; + _style = "default"; + _label = ""; + _uda = true; _hyphenate = (_type == "string") ? true : false; - - _styles.push_back (_style); - _styles.push_back ("indicator"); + _styles = {_style, "indicator"}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColUUID.cpp b/src/columns/ColUUID.cpp index f267c0eee..80ed98331 100644 --- a/src/columns/ColUUID.cpp +++ b/src/columns/ColUUID.cpp @@ -41,12 +41,8 @@ ColumnUUID::ColumnUUID () _style = "long"; _label = STRING_COLUMN_LABEL_UUID; _modifiable = false; - - _styles.push_back ("long"); - _styles.push_back ("short"); - - _examples.push_back ("f30cb9c3-3fc0-483f-bfb2-3bf134f00694"); - _examples.push_back ("f30cb9c3"); + _styles = {"long", "short"}; + _examples = {"f30cb9c3-3fc0-483f-bfb2-3bf134f00694", "f30cb9c3"}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColUrgency.cpp b/src/columns/ColUrgency.cpp index 4b8dc8776..dc47bce3e 100644 --- a/src/columns/ColUrgency.cpp +++ b/src/columns/ColUrgency.cpp @@ -35,16 +35,12 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnUrgency::ColumnUrgency () { - _name = "urgency"; - _type = "numeric"; - _style = "real"; - _label = STRING_COLUMN_LABEL_URGENCY; - - _styles.push_back ("real"); - _styles.push_back ("integer"); - - _examples.push_back ("4.6"); - _examples.push_back ("4"); + _name = "urgency"; + _type = "numeric"; + _style = "real"; + _label = STRING_COLUMN_LABEL_URGENCY; + _styles = {"real", "integer"}; + _examples = {"4.6", "4"}; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/util.cpp b/src/util.cpp index 697db3253..b4c048668 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -65,9 +65,8 @@ extern Context context; // std::getline, the newline can be detected, and the prompt re-written. bool confirm (const std::string& question) { - std::vector options; - options.push_back (STRING_UTIL_CONFIRM_YES); - options.push_back (STRING_UTIL_CONFIRM_NO); + std::vector options {STRING_UTIL_CONFIRM_YES, + STRING_UTIL_CONFIRM_NO}; std::string answer; std::vector matches; @@ -94,13 +93,12 @@ bool confirm (const std::string& question) // 3 = quit int confirm4 (const std::string& question) { - std::vector options; - options.push_back (STRING_UTIL_CONFIRM_YES_U); - options.push_back (STRING_UTIL_CONFIRM_YES); - options.push_back (STRING_UTIL_CONFIRM_NO); - options.push_back (STRING_UTIL_CONFIRM_ALL_U); - options.push_back (STRING_UTIL_CONFIRM_ALL); - options.push_back (STRING_UTIL_CONFIRM_QUIT); + std::vector options {STRING_UTIL_CONFIRM_YES_U, + STRING_UTIL_CONFIRM_YES, + STRING_UTIL_CONFIRM_NO, + STRING_UTIL_CONFIRM_ALL_U, + STRING_UTIL_CONFIRM_ALL, + STRING_UTIL_CONFIRM_QUIT}; std::string answer; std::vector matches; diff --git a/test/autocomplete.t.cpp b/test/autocomplete.t.cpp index a2b011532..e18dc8d95 100644 --- a/test/autocomplete.t.cpp +++ b/test/autocomplete.t.cpp @@ -42,13 +42,7 @@ int main (int argc, char** argv) unsetenv ("TASKDATA"); unsetenv ("TASKRC"); - std::vector options; - options.push_back ("abc"); - options.push_back ("abcd"); - options.push_back ("abcde"); - options.push_back ("bcdef"); - options.push_back ("cdefg"); - + std::vector options {"abc", "abcd", "abcde", "bcdef", "cdefg"}; std::vector matches; int result = autoComplete ("", options, matches); t.is (result, 0, "no match on empty string"); diff --git a/test/list.t.cpp b/test/list.t.cpp index 97fa43ff9..5a427f6d7 100644 --- a/test/list.t.cpp +++ b/test/list.t.cpp @@ -43,21 +43,9 @@ int main (int argc, char** argv) unsetenv ("TASKRC"); // 1,2,3 <=> 2,3,4 - std::vector string_one; - string_one.push_back ("1"); - string_one.push_back ("2"); - string_one.push_back ("3"); - - std::vector string_two; - string_two.push_back ("2"); - string_two.push_back ("3"); - string_two.push_back ("4"); - - std::vector string_three; - string_three.push_back ("2"); - string_three.push_back ("3"); - string_three.push_back ("4"); - + std::vector string_one {"1", "2", "3"}; + std::vector string_two {"2", "3", "4"}; + std::vector string_three {"2", "3", "4"}; std::vector string_four; // Differences? @@ -87,21 +75,9 @@ int main (int argc, char** argv) // Now do it all again, with integers. // 1,2,3 <=> 2,3,4 - std::vector int_one; - int_one.push_back (1); - int_one.push_back (2); - int_one.push_back (3); - - std::vector int_two; - int_two.push_back (2); - int_two.push_back (3); - int_two.push_back (4); - - std::vector int_three; - int_three.push_back (2); - int_three.push_back (3); - int_three.push_back (4); - + std::vector int_one {1, 2, 3}; + std::vector int_two {2, 3, 4}; + std::vector int_three {2, 3, 4}; std::vector int_four; // Differences? diff --git a/test/nibbler.t.cpp b/test/nibbler.t.cpp index 886153b97..29e22a8c4 100644 --- a/test/nibbler.t.cpp +++ b/test/nibbler.t.cpp @@ -634,9 +634,7 @@ int main (int argc, char** argv) // bool getOneOf (const std::vector &, std::string&); t.diag ("Nibbler::getOneOf"); - options.push_back ("one"); - options.push_back ("two"); - options.push_back ("three"); + options = {"one", "two", "three"}; n = Nibbler ("onetwothreefour"); t.ok (n.getOneOf (options, s), "'onetwothreefour': getOneOf () -> true"); t.is (s, "one", "'onetwothreefour': getOneOf () -> one"); diff --git a/test/text.t.cpp b/test/text.t.cpp index 57c33768d..e4013f86b 100644 --- a/test/text.t.cpp +++ b/test/text.t.cpp @@ -171,10 +171,7 @@ int main (int argc, char** argv) t.is (joined.length (), (size_t) 0, "join -> length 0"); t.is (joined, "", "join -> ''"); - unjoined.push_back (""); - unjoined.push_back ("a"); - unjoined.push_back ("bc"); - unjoined.push_back ("def"); + unjoined = {"", "a", "bc", "def"}; join (joined, "", unjoined); t.is (joined.length (), (size_t) 6, "join '' 'a' 'bc' 'def' -> length 6"); t.is (joined, "abcdef", "join '' 'a' 'bc' 'def' -> 'abcdef'"); @@ -190,9 +187,7 @@ int main (int argc, char** argv) t.is (joined.length (), (size_t) 0, "join -> length 0"); t.is (joined, "", "join -> ''"); - unjoined2.push_back (0); - unjoined2.push_back (1); - unjoined2.push_back (2); + unjoined2 = {0, 1, 2}; join (joined, "", unjoined2); t.is (joined.length (), (size_t) 3, "join 0 1 2 -> length 3"); t.is (joined, "012", "join 0 1 2 -> '012'");