Skip to content
Permalink
Browse files

Add curly braces

  • Loading branch information...
lauft committed Feb 26, 2019
1 parent 44ed56a commit 04adb50480f567b9c0a2a9f54be061abce0a671c
Showing with 26 additions and 0 deletions.
  1. +14 −0 src/Database.cpp
  2. +4 −0 src/commands/CmdJoin.cpp
  3. +8 −0 src/util.cpp
@@ -56,7 +56,9 @@ std::vector <std::string> Database::files () const
{
std::vector <std::string> all;
for (auto& file : _files)
{
all.push_back (file.name ());
}

return all;
}
@@ -75,7 +77,9 @@ std::string Database::lastLine ()
{
auto line = ri->lastLine ();
if (! line.empty ())
{
return line;
}
}

return "";
@@ -272,7 +276,9 @@ std::string Database::dump () const
std::stringstream out;
out << "Database\n";
for (auto& df : _files)
{
out << df.dump ();
}

return out.str ();
}
@@ -292,8 +298,12 @@ unsigned int Database::getDatafile (int year, int month)

// If the datafile is already initialized, return.
for (unsigned int i = 0; i < _files.size (); ++i)
{
if (_files[i].name () == basename)
{
return i;
}
}

// Create the Datafile.
Datafile df;
@@ -325,7 +335,9 @@ std::vector <Range> Database::segmentRange (const Range& range)

auto end = range.end;
if (end.toEpoch () == 0)
{
end = Datetime ();
}

auto end_y = end.year ();
auto end_m = end.month ();
@@ -374,7 +386,9 @@ void Database::initializeTagDatabase ()
auto* value = (json::object*) pair.second;
auto iter = value->_data.find ("count");
if (iter == value->_data.end ())
{
throw format ("Failed to find \"count\" member for tag \"{1}\" in tags database. Database corrupted?", key);
}
auto number = static_cast<json::number *> (iter->second);
_tagInfoDatabase.add (key, TagInfo {(unsigned int) number->_dvalue});
}
@@ -43,7 +43,9 @@ int CmdJoin (

// Only 2 IDs allowed in a join.
if (ids.size () != 2)
{
throw std::string ("Two IDs must be specified. See 'timew help join'.");
}

// Load the data.
// Note: There is no filter.
@@ -87,7 +89,9 @@ int CmdJoin (
database.endTransaction ();

if (rules.getBoolean ("verbose"))
{
std::cout << "Joined @" << first_id << " and @" << second_id << '\n';
}

return 0;
}
@@ -55,7 +55,9 @@ std::string escape (const std::string& input, int c)
std::string quoteIfNeeded (const std::string& input)
{
if (input[0] == '"' || input[0] == '\'')
{
return input;
}

auto quote = input.find ('"');
auto space = input.find (' ');
@@ -64,13 +66,19 @@ std::string quoteIfNeeded (const std::string& input)
if (quote == std::string::npos &&
space == std::string::npos &&
op == std::string::npos)
{
return input;
}

std::string output;
if (quote != std::string::npos)
{
output = escape (input, '"');
}
else
{
output = input;
}

return std::string ("\"") + output + "\"";
}

0 comments on commit 04adb50

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.