Code Cleanup

- All objects now use the same convention for naming members.  The
  consistency is a good thing.
This commit is contained in:
Paul Beckingham
2011-08-25 21:54:28 -04:00
parent fb6dc5058f
commit dab06f8672
53 changed files with 1347 additions and 1349 deletions

View File

@@ -300,13 +300,13 @@ void A3::rc_override (
rc = File (arg->_raw.substr (3)); rc = File (arg->_raw.substr (3));
home = rc; home = rc;
std::string::size_type last_slash = rc.data.rfind ("/"); std::string::size_type last_slash = rc._data.rfind ("/");
if (last_slash != std::string::npos) if (last_slash != std::string::npos)
home = rc.data.substr (0, last_slash); home = rc._data.substr (0, last_slash);
else else
home = "."; home = ".";
context.header ("Using alternate .taskrc file " + rc.data); context.header ("Using alternate .taskrc file " + rc._data);
// Keep looping, because if there are multiple rc:file arguments, we // Keep looping, because if there are multiple rc:file arguments, we
// want the last one to dominate. // want the last one to dominate.

View File

@@ -135,17 +135,17 @@ static int api_task_set (lua_State* L)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
API::API () API::API ()
: L (NULL) : _L (NULL)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
API::~API () API::~API ()
{ {
if (L) if (_L)
{ {
lua_close (L); lua_close (_L);
L = NULL; _L = NULL;
} }
} }
@@ -153,16 +153,16 @@ API::~API ()
void API::initialize () void API::initialize ()
{ {
// Initialize Lua. // Initialize Lua.
L = lua_open (); _L = lua_open ();
luaL_openlibs (L); // TODO Error handling luaL_openlibs (_L); // TODO Error handling
// Register all the API functions in Lua global space. // Register all the API functions in Lua global space.
lua_pushcfunction (L, api_task_header_message); lua_setglobal (L, "task_header_message"); lua_pushcfunction (_L, api_task_header_message); lua_setglobal (_L, "task_header_message");
lua_pushcfunction (L, api_task_footnote_message); lua_setglobal (L, "task_footnote_message"); lua_pushcfunction (_L, api_task_footnote_message); lua_setglobal (_L, "task_footnote_message");
lua_pushcfunction (L, api_task_debug_message); lua_setglobal (L, "task_debug_message"); lua_pushcfunction (_L, api_task_debug_message); lua_setglobal (_L, "task_debug_message");
lua_pushcfunction (L, api_task_exit); lua_setglobal (L, "task_exit"); lua_pushcfunction (_L, api_task_exit); lua_setglobal (_L, "task_exit");
lua_pushcfunction (L, api_task_get); lua_setglobal (L, "task_get"); lua_pushcfunction (_L, api_task_get); lua_setglobal (_L, "task_get");
lua_pushcfunction (L, api_task_set); lua_setglobal (L, "task_set"); lua_pushcfunction (_L, api_task_set); lua_setglobal (_L, "task_set");
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -173,26 +173,26 @@ bool API::callProgramHook (
loadFile (file); loadFile (file);
// Get function. // Get function.
lua_getglobal (L, function.c_str ()); lua_getglobal (_L, function.c_str ());
if (!lua_isfunction (L, -1)) if (!lua_isfunction (_L, -1))
{ {
lua_pop (L, 1); lua_pop (_L, 1);
throw format (STRING_API_NOFUNC, function); throw format (STRING_API_NOFUNC, function);
} }
// Make call. // Make call.
if (lua_pcall (L, 0, 2, 0) != 0) if (lua_pcall (_L, 0, 2, 0) != 0)
throw format (STRING_API_ERROR_CALLING, function, lua_tostring (L, -1)); throw format (STRING_API_ERROR_CALLING, function, lua_tostring (_L, -1));
// Call successful - get return values. // Call successful - get return values.
if (!lua_isnumber (L, -2)) if (!lua_isnumber (_L, -2))
throw format (STRING_API_ERROR_FAIL, function); throw format (STRING_API_ERROR_FAIL, function);
if (!lua_isstring (L, -1) && !lua_isnil (L, -1)) if (!lua_isstring (_L, -1) && !lua_isnil (_L, -1))
throw format (STRING_API_ERROR_NORET, function); throw format (STRING_API_ERROR_NORET, function);
int rc = lua_tointeger (L, -2); int rc = lua_tointeger (_L, -2);
const char* message = lua_tostring (L, -1); const char* message = lua_tostring (_L, -1);
if (rc == 0) if (rc == 0)
{ {
@@ -205,7 +205,7 @@ bool API::callProgramHook (
throw std::string (message); throw std::string (message);
} }
lua_pop (L, 1); lua_pop (_L, 1);
return rc == 0 ? true : false; return rc == 0 ? true : false;
} }
@@ -218,32 +218,32 @@ bool API::callTaskHook (
loadFile (file); loadFile (file);
// Save the task for reference via the API. // Save the task for reference via the API.
current = task; _current = task;
// Get function. // Get function.
lua_getglobal (L, function.c_str ()); lua_getglobal (_L, function.c_str ());
if (!lua_isfunction (L, -1)) if (!lua_isfunction (_L, -1))
{ {
lua_pop (L, 1); lua_pop (_L, 1);
throw format (STRING_API_NOFUNC, function); throw format (STRING_API_NOFUNC, function);
} }
// Prepare args. // Prepare args.
lua_pushnumber (L, current.id); lua_pushnumber (_L, _current.id);
// Make call. // Make call.
if (lua_pcall (L, 1, 2, 0) != 0) if (lua_pcall (_L, 1, 2, 0) != 0)
throw format (STRING_API_ERROR_CALLING, function, lua_tostring (L, -1)); throw format (STRING_API_ERROR_CALLING, function, lua_tostring (_L, -1));
// Call successful - get return values. // Call successful - get return values.
if (!lua_isnumber (L, -2)) if (!lua_isnumber (_L, -2))
throw format (STRING_API_ERROR_FAIL, function); throw format (STRING_API_ERROR_FAIL, function);
if (!lua_isstring (L, -1) && !lua_isnil (L, -1)) if (!lua_isstring (_L, -1) && !lua_isnil (_L, -1))
throw format (STRING_API_ERROR_NORET, function); throw format (STRING_API_ERROR_NORET, function);
int rc = lua_tointeger (L, -2); int rc = lua_tointeger (_L, -2);
const char* message = lua_tostring (L, -1); const char* message = lua_tostring (_L, -1);
if (rc == 0) if (rc == 0)
{ {
@@ -256,7 +256,7 @@ bool API::callTaskHook (
throw std::string (message); throw std::string (message);
} }
lua_pop (L, 1); lua_pop (_L, 1);
return rc == 0 ? true : false; return rc == 0 ? true : false;
} }
@@ -264,14 +264,14 @@ bool API::callTaskHook (
void API::loadFile (const std::string& file) void API::loadFile (const std::string& file)
{ {
// If the file is not loaded. // If the file is not loaded.
if (std::find (loaded.begin (), loaded.end (), file) == loaded.end ()) if (std::find (_loaded.begin (), _loaded.end (), file) == _loaded.end ())
{ {
// Load the file, if possible. // Load the file, if possible.
if (luaL_loadfile (L, file.c_str ()) || lua_pcall (L, 0, 0, 0)) if (luaL_loadfile (_L, file.c_str ()) || lua_pcall (_L, 0, 0, 0))
throw format (STRING_API_ERROR, lua_tostring (L, -1)); throw format (STRING_API_ERROR, lua_tostring (_L, -1));
// Mark this as loaded, so as to not bother again. // Mark this as _loaded, so as to not bother again.
loaded.push_back (file); _loaded.push_back (file);
} }
} }

View File

@@ -58,12 +58,12 @@ private:
void loadFile (const std::string&); void loadFile (const std::string&);
public: public:
lua_State* L; lua_State* _L;
std::vector <std::string> loaded; std::vector <std::string> _loaded;
// Context for the API. // Context for the API.
// std::vector <Task> all; // std::vector <Task> all;
Task current; Task _current;
// std::string& name; // std::string& name;
// std::string& value; // std::string& value;
}; };

View File

@@ -110,74 +110,74 @@ static inline std::string& str_replace (
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Att::Att () Att::Att ()
: mName ("") : _name ("")
, mValue ("") , _value ("")
, mMod ("") , _mod ("")
, mSense ("positive") , _sense ("positive")
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Att::Att (const std::string& name, const std::string& mod, const std::string& value) Att::Att (const std::string& name, const std::string& mod, const std::string& value)
{ {
mName = name; _name = name;
mValue = value; _value = value;
mMod = mod; _mod = mod;
mSense = "positive"; _sense = "positive";
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Att::Att (const std::string& name, const std::string& mod, const std::string& value, Att::Att (const std::string& name, const std::string& mod, const std::string& value,
const std::string& sense) const std::string& sense)
{ {
mName = name; _name = name;
mValue = value; _value = value;
mMod = mod; _mod = mod;
mSense = sense; _sense = sense;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Att::Att (const std::string& name, const std::string& mod, int value) Att::Att (const std::string& name, const std::string& mod, int value)
{ {
mName = name; _name = name;
std::stringstream s; std::stringstream s;
s << value; s << value;
mValue = s.str (); _value = s.str ();
mMod = mod; _mod = mod;
mSense = "positive"; _sense = "positive";
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Att::Att (const std::string& name, const std::string& value) Att::Att (const std::string& name, const std::string& value)
{ {
mName = name; _name = name;
mValue = value; _value = value;
mMod = ""; _mod = "";
mSense = "positive"; _sense = "positive";
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Att::Att (const std::string& name, int value) Att::Att (const std::string& name, int value)
{ {
mName = name; _name = name;
std::stringstream s; std::stringstream s;
s << value; s << value;
mValue = s.str (); _value = s.str ();
mMod = ""; _mod = "";
mSense = "positive"; _sense = "positive";
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Att::Att (const Att& other) Att::Att (const Att& other)
{ {
mName = other.mName; _name = other._name;
mValue = other.mValue; _value = other._value;
mMod = other.mMod; _mod = other._mod;
mSense = other.mSense; _sense = other._sense;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -185,10 +185,10 @@ Att& Att::operator= (const Att& other)
{ {
if (this != &other) if (this != &other)
{ {
mName = other.mName; _name = other._name;
mValue = other.mValue; _value = other._value;
mMod = other.mMod; _mod = other._mod;
mSense = other.mSense; _sense = other._sense;
} }
return *this; return *this;
@@ -197,10 +197,10 @@ Att& Att::operator= (const Att& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Att::operator== (const Att& other) const bool Att::operator== (const Att& other) const
{ {
return mName == other.mName && return _name == other._name &&
mMod == other.mMod && _mod == other._mod &&
mValue == other.mValue && _value == other._value &&
mSense == other.mSense; _sense == other._sense;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -211,14 +211,14 @@ Att::~Att ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Att::logicSense (bool match) const bool Att::logicSense (bool match) const
{ {
if (mSense == "positive") if (_sense == "positive")
return match; return match;
else if (mSense == "negative") else if (_sense == "negative")
return ! match; return ! match;
else else
{ {
context.debug ("mSense: " + mSense); context.debug ("_sense: " + _sense);
throw ("unknown mSense " + mSense); throw ("unknown _sense " + _sense);
} }
} }
@@ -534,14 +534,14 @@ void Att::parse (const std::string& input)
void Att::parse (Nibbler& n) void Att::parse (Nibbler& n)
{ {
// Ensure a clean object first. // Ensure a clean object first.
mName = ""; _name = "";
mValue = ""; _value = "";
mMod = ""; _mod = "";
mSense = "positive"; _sense = "positive";
if (n.getUntilOneOf (".:", mName)) if (n.getUntilOneOf (".:", _name))
{ {
if (mName.length () == 0) if (_name.length () == 0)
throw std::string ("Missing attribute name"); // TODO i18n throw std::string ("Missing attribute name"); // TODO i18n
if (n.skip ('.')) if (n.skip ('.'))
@@ -551,13 +551,13 @@ void Att::parse (Nibbler& n)
if (n.skip ('~')) if (n.skip ('~'))
{ {
context.debug ("using negative logic"); context.debug ("using negative logic");
mSense = "negative"; _sense = "negative";
} }
if (n.getUntil (":", mod)) if (n.getUntil (":", mod))
{ {
if (validMod (mod)) if (validMod (mod))
mMod = mod; _mod = mod;
else else
throw std::string ("The name '") + mod + "' is not a valid modifier."; // TODO i18n throw std::string ("The name '") + mod + "' is not a valid modifier."; // TODO i18n
} }
@@ -569,10 +569,10 @@ void Att::parse (Nibbler& n)
{ {
// Both quoted and unquoted Att's are accepted. // Both quoted and unquoted Att's are accepted.
// Consider removing this for a stricter parse. // Consider removing this for a stricter parse.
if (n.getQuoted ('"', mValue) || if (n.getQuoted ('"', _value) ||
n.getUntilEOS (mValue)) n.getUntilEOS (_value))
{ {
decode (mValue); decode (_value);
} }
} }
else else
@@ -582,7 +582,7 @@ void Att::parse (Nibbler& n)
throw std::string ("Missing : after attribute name."); // TODO i18n throw std::string ("Missing : after attribute name."); // TODO i18n
/* TODO This might be too slow to include. Test this assumption. /* TODO This might be too slow to include. Test this assumption.
validNameValue (mName, mMod, mValue); validNameValue (_name, _mod, _value);
*/ */
} }
@@ -592,13 +592,13 @@ std::string Att::composeF4 () const
{ {
std::string output = ""; std::string output = "";
if (mName != "" && mValue != "") if (_name != "" && _value != "")
{ {
std::string value = mValue; std::string value = _value;
encode (value); encode (value);
enquote (value); enquote (value);
output += mName + ":" + value; output += _name + ":" + value;
} }
return output; return output;
@@ -610,37 +610,37 @@ void Att::mod (const std::string& input)
if (input != "" && !validMod (input)) if (input != "" && !validMod (input))
throw std::string ("The name '") + input + "' is not a valid modifier."; // TODO i18n throw std::string ("The name '") + input + "' is not a valid modifier."; // TODO i18n
mMod = input; _mod = input;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Att::mod () const std::string Att::mod () const
{ {
return mMod; return _mod;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Att::name () const std::string Att::name () const
{ {
return mName; return _name;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Att::name (const std::string& name) void Att::name (const std::string& name)
{ {
mName = name; _name = name;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Att::value () const std::string Att::value () const
{ {
return mValue; return _value;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Att::value (const std::string& value) void Att::value (const std::string& value)
{ {
mValue = value; _value = value;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@@ -77,10 +77,10 @@ private:
void decode (std::string&) const; void decode (std::string&) const;
private: private:
std::string mName; std::string _name;
std::string mValue; std::string _value;
std::string mMod; std::string _mod;
std::string mSense; std::string _sense;
}; };
#endif #endif

View File

@@ -62,26 +62,26 @@ static struct
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Color::Color () Color::Color ()
: value (0) : _value (0)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Color::Color (const Color& other) Color::Color (const Color& other)
{ {
value = other.value; _value = other._value;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Color::Color (unsigned int c) Color::Color (unsigned int c)
: value (0) : _value (0)
{ {
if (!(c & _COLOR_HASFG)) value &= ~_COLOR_FG; if (!(c & _COLOR_HASFG)) _value &= ~_COLOR_FG;
if (!(c & _COLOR_HASBG)) value &= ~_COLOR_BG; if (!(c & _COLOR_HASBG)) _value &= ~_COLOR_BG;
value = c & (_COLOR_256 | _COLOR_HASBG | _COLOR_HASFG |_COLOR_UNDERLINE | _value = c & (_COLOR_256 | _COLOR_HASBG | _COLOR_HASFG |_COLOR_UNDERLINE |
_COLOR_INVERSE | _COLOR_BOLD | _COLOR_BRIGHT | _COLOR_BG | _COLOR_INVERSE | _COLOR_BOLD | _COLOR_BRIGHT | _COLOR_BG |
_COLOR_FG); _COLOR_FG);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -97,7 +97,7 @@ Color::Color (unsigned int c)
// colorN 0 <= N <= 255 fg 38;5;N bg 48;5;N // colorN 0 <= N <= 255 fg 38;5;N bg 48;5;N
// rgbRGB 0 <= R,G,B <= 5 fg 38;5;16 + R*36 + G*6 + B bg 48;5;16 + R*36 + G*6 + B // rgbRGB 0 <= R,G,B <= 5 fg 38;5;16 + R*36 + G*6 + B bg 48;5;16 + R*36 + G*6 + B
Color::Color (const std::string& spec) Color::Color (const std::string& spec)
: value (0) : _value (0)
{ {
// By converting underscores to spaces, we inherently support the old "on_red" // By converting underscores to spaces, we inherently support the old "on_red"
// style of specifying background colors. We consider underscores to be // style of specifying background colors. We consider underscores to be
@@ -228,56 +228,56 @@ Color::Color (const std::string& spec)
} }
// Now combine the fg and bg into a single color. // Now combine the fg and bg into a single color.
value = fg_value; _value = fg_value;
blend (Color (bg_value)); blend (Color (bg_value));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Color::Color (color_id fg) Color::Color (color_id fg)
: value (0) : _value (0)
{ {
if (fg != Color::nocolor) if (fg != Color::nocolor)
{ {
value |= _COLOR_HASFG; _value |= _COLOR_HASFG;
value |= fg; _value |= fg;
} }
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Color::Color (color_id fg, color_id bg) Color::Color (color_id fg, color_id bg)
: value (0) : _value (0)
{ {
if (bg != Color::nocolor) if (bg != Color::nocolor)
{ {
value |= _COLOR_HASBG; _value |= _COLOR_HASBG;
value |= (bg << 8); _value |= (bg << 8);
} }
if (fg != Color::nocolor) if (fg != Color::nocolor)
{ {
value |= _COLOR_HASFG; _value |= _COLOR_HASFG;
value |= fg; _value |= fg;
} }
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Color::Color (color_id fg, color_id bg, bool underline, bool bold, bool bright) Color::Color (color_id fg, color_id bg, bool underline, bool bold, bool bright)
: value (0) : _value (0)
{ {
value |= ((underline ? 1 : 0) << 18) _value |= ((underline ? 1 : 0) << 18)
| ((bold ? 1 : 0) << 17) | ((bold ? 1 : 0) << 17)
| ((bright ? 1 : 0) << 16); | ((bright ? 1 : 0) << 16);
if (bg != Color::nocolor) if (bg != Color::nocolor)
{ {
value |= _COLOR_HASBG; _value |= _COLOR_HASBG;
value |= (bg << 8); _value |= (bg << 8);
} }
if (fg != Color::nocolor) if (fg != Color::nocolor)
{ {
value |= _COLOR_HASFG; _value |= _COLOR_HASFG;
value |= fg; _value |= fg;
} }
} }
@@ -290,7 +290,7 @@ Color::~Color ()
Color& Color::operator= (const Color& other) Color& Color::operator= (const Color& other)
{ {
if (this != &other) if (this != &other)
value = other.value; _value = other._value;
return *this; return *this;
} }
@@ -299,22 +299,22 @@ Color& Color::operator= (const Color& other)
Color::operator std::string () const Color::operator std::string () const
{ {
std::string description; std::string description;
if (value & _COLOR_BOLD) description += "bold"; if (_value & _COLOR_BOLD) description += "bold";
if (value & _COLOR_UNDERLINE) if (_value & _COLOR_UNDERLINE)
description += std::string (description.length () ? " " : "") + "underline"; description += std::string (description.length () ? " " : "") + "underline";
if (value & _COLOR_INVERSE) if (_value & _COLOR_INVERSE)
description += std::string (description.length () ? " " : "") + "inverse"; description += std::string (description.length () ? " " : "") + "inverse";
if (value & _COLOR_HASFG) if (_value & _COLOR_HASFG)
description += std::string (description.length () ? " " : "") + fg (); description += std::string (description.length () ? " " : "") + fg ();
if (value & _COLOR_HASBG) if (_value & _COLOR_HASBG)
{ {
description += std::string (description.length () ? " " : "") + "on"; description += std::string (description.length () ? " " : "") + "on";
if (value & _COLOR_BRIGHT) if (_value & _COLOR_BRIGHT)
description += std::string (description.length () ? " " : "") + "bright"; description += std::string (description.length () ? " " : "") + "bright";
description += " " + bg (); description += " " + bg ();
@@ -326,7 +326,7 @@ Color::operator std::string () const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Color::operator int () const Color::operator int () const
{ {
return (int) value; return (int) _value;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -335,28 +335,28 @@ Color::operator int () const
void Color::blend (const Color& other) void Color::blend (const Color& other)
{ {
Color c (other); Color c (other);
value |= (c.value & _COLOR_UNDERLINE); // Always inherit underline. _value |= (c._value & _COLOR_UNDERLINE); // Always inherit underline.
value |= (c.value & _COLOR_INVERSE); // Always inherit inverse. _value |= (c._value & _COLOR_INVERSE); // Always inherit inverse.
// 16 <-- 16. // 16 <-- 16.
if (!(value & _COLOR_256) && if (!(_value & _COLOR_256) &&
!(c.value & _COLOR_256)) !(c._value & _COLOR_256))
{ {
value |= (c.value & _COLOR_BOLD); // Inherit bold. _value |= (c._value & _COLOR_BOLD); // Inherit bold.
value |= (c.value & _COLOR_BRIGHT); // Inherit bright. _value |= (c._value & _COLOR_BRIGHT); // Inherit bright.
if (c.value & _COLOR_HASFG) if (c._value & _COLOR_HASFG)
{ {
value |= _COLOR_HASFG; // There is now a color. _value |= _COLOR_HASFG; // There is now a color.
value &= ~_COLOR_FG; // Remove previous color. _value &= ~_COLOR_FG; // Remove previous color.
value |= (c.value & _COLOR_FG); // Apply other color. _value |= (c._value & _COLOR_FG); // Apply other color.
} }
if (c.value & _COLOR_HASBG) if (c._value & _COLOR_HASBG)
{ {
value |= _COLOR_HASBG; // There is now a color. _value |= _COLOR_HASBG; // There is now a color.
value &= ~_COLOR_BG; // Remove previous color. _value &= ~_COLOR_BG; // Remove previous color.
value |= (c.value & _COLOR_BG); // Apply other color. _value |= (c._value & _COLOR_BG); // Apply other color.
} }
return; return;
@@ -364,22 +364,22 @@ void Color::blend (const Color& other)
else else
{ {
// Upgrade either color, if necessary. // Upgrade either color, if necessary.
if (!(value & _COLOR_256)) upgrade (); if (!(_value & _COLOR_256)) upgrade ();
if (!(c.value & _COLOR_256)) c.upgrade (); if (!(c._value & _COLOR_256)) c.upgrade ();
// 256 <-- 256. // 256 <-- 256.
if (c.value & _COLOR_HASFG) if (c._value & _COLOR_HASFG)
{ {
value |= _COLOR_HASFG; // There is now a color. _value |= _COLOR_HASFG; // There is now a color.
value &= ~_COLOR_FG; // Remove previous color. _value &= ~_COLOR_FG; // Remove previous color.
value |= (c.value & _COLOR_FG); // Apply other color. _value |= (c._value & _COLOR_FG); // Apply other color.
} }
if (c.value & _COLOR_HASBG) if (c._value & _COLOR_HASBG)
{ {
value |= _COLOR_HASBG; // There is now a color. _value |= _COLOR_HASBG; // There is now a color.
value &= ~_COLOR_BG; // Remove previous color. _value &= ~_COLOR_BG; // Remove previous color.
value |= (c.value & _COLOR_BG); // Apply other color. _value |= (c._value & _COLOR_BG); // Apply other color.
} }
} }
} }
@@ -387,27 +387,27 @@ void Color::blend (const Color& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Color::upgrade () void Color::upgrade ()
{ {
if (!(value & _COLOR_256)) if (!(_value & _COLOR_256))
{ {
if (value & _COLOR_HASFG) if (_value & _COLOR_HASFG)
{ {
bool bold = value & _COLOR_BOLD; bool bold = _value & _COLOR_BOLD;
unsigned int fg = value & _COLOR_FG; unsigned int fg = _value & _COLOR_FG;
value &= ~_COLOR_FG; _value &= ~_COLOR_FG;
value &= ~_COLOR_BOLD; _value &= ~_COLOR_BOLD;
value |= (bold ? fg + 7 : fg - 1); _value |= (bold ? fg + 7 : fg - 1);
} }
if (value & _COLOR_HASBG) if (_value & _COLOR_HASBG)
{ {
bool bright = value & _COLOR_BRIGHT; bool bright = _value & _COLOR_BRIGHT;
unsigned int bg = (value & _COLOR_BG) >> 8; unsigned int bg = (_value & _COLOR_BG) >> 8;
value &= ~_COLOR_BG; _value &= ~_COLOR_BG;
value &= ~_COLOR_BRIGHT; _value &= ~_COLOR_BRIGHT;
value |= (bright ? bg + 7 : bg - 1) << 8; _value |= (bright ? bg + 7 : bg - 1) << 8;
} }
value |= _COLOR_256; _value |= _COLOR_256;
} }
} }
@@ -425,38 +425,38 @@ void Color::upgrade ()
// 256 bg \033[48;5;Nm // 256 bg \033[48;5;Nm
std::string Color::colorize (const std::string& input) std::string Color::colorize (const std::string& input)
{ {
if (value == 0) if (_value == 0)
return input; return input;
int count = 0; int count = 0;
std::stringstream result; std::stringstream result;
// 256 color // 256 color
if (value & _COLOR_256) if (_value & _COLOR_256)
{ {
bool needTerminator = false; bool needTerminator = false;
if (value & _COLOR_UNDERLINE) if (_value & _COLOR_UNDERLINE)
{ {
result << "\033[4m"; result << "\033[4m";
needTerminator = true; needTerminator = true;
} }
if (value & _COLOR_INVERSE) if (_value & _COLOR_INVERSE)
{ {
result << "\033[7m"; result << "\033[7m";
needTerminator = true; needTerminator = true;
} }
if (value & _COLOR_HASFG) if (_value & _COLOR_HASFG)
{ {
result << "\033[38;5;" << (value & _COLOR_FG) << "m"; result << "\033[38;5;" << (_value & _COLOR_FG) << "m";
needTerminator = true; needTerminator = true;
} }
if (value & _COLOR_HASBG) if (_value & _COLOR_HASBG)
{ {
result << "\033[48;5;" << ((value & _COLOR_BG) >> 8) << "m"; result << "\033[48;5;" << ((_value & _COLOR_BG) >> 8) << "m";
needTerminator = true; needTerminator = true;
} }
@@ -468,38 +468,38 @@ std::string Color::colorize (const std::string& input)
} }
// 16 color // 16 color
if (value != 0) if (_value != 0)
{ {
result << "\033["; result << "\033[";
if (value & _COLOR_BOLD) if (_value & _COLOR_BOLD)
{ {
if (count++) result << ";"; if (count++) result << ";";
result << "1"; result << "1";
} }
if (value & _COLOR_UNDERLINE) if (_value & _COLOR_UNDERLINE)
{ {
if (count++) result << ";"; if (count++) result << ";";
result << "4"; result << "4";
} }
if (value & _COLOR_INVERSE) if (_value & _COLOR_INVERSE)
{ {
if (count++) result << ";"; if (count++) result << ";";
result << "7"; result << "7";
} }
if (value & _COLOR_HASFG) if (_value & _COLOR_HASFG)
{ {
if (count++) result << ";"; if (count++) result << ";";
result << (29 + (value & _COLOR_FG)); result << (29 + (_value & _COLOR_FG));
} }
if (value & _COLOR_HASBG) if (_value & _COLOR_HASBG)
{ {
if (count++) result << ";"; if (count++) result << ";";
result << ((value & _COLOR_BRIGHT ? 99 : 39) + ((value & _COLOR_BG) >> 8)); result << ((_value & _COLOR_BRIGHT ? 99 : 39) + ((_value & _COLOR_BG) >> 8));
} }
result << "m" << input << "\033[0m"; result << "m" << input << "\033[0m";
@@ -545,7 +545,7 @@ std::string Color::colorize (const std::string& input, const std::string& spec)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Color::nontrivial () bool Color::nontrivial ()
{ {
return value != 0 ? true : false; return _value != 0 ? true : false;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -561,14 +561,14 @@ int Color::find (const std::string& input)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Color::fg () const std::string Color::fg () const
{ {
int index = value & _COLOR_FG; int index = _value & _COLOR_FG;
if (value & _COLOR_256) if (_value & _COLOR_256)
{ {
if (value & _COLOR_HASFG) if (_value & _COLOR_HASFG)
{ {
std::stringstream s; std::stringstream s;
s << "color" << (value & _COLOR_FG); s << "color" << (_value & _COLOR_FG);
return s.str (); return s.str ();
} }
} }
@@ -585,14 +585,14 @@ std::string Color::fg () const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Color::bg () const std::string Color::bg () const
{ {
int index = (value & _COLOR_BG) >> 8; int index = (_value & _COLOR_BG) >> 8;
if (value & _COLOR_256) if (_value & _COLOR_256)
{ {
if (value & _COLOR_HASBG) if (_value & _COLOR_HASBG)
{ {
std::stringstream s; std::stringstream s;
s << "color" << ((value & _COLOR_BG) >> 8); s << "color" << ((_value & _COLOR_BG) >> 8);
return s.str (); return s.str ();
} }
} }

View File

@@ -73,7 +73,7 @@ private:
std::string bg () const; std::string bg () const;
private: private:
unsigned int value; unsigned int _value;
}; };
#endif #endif

View File

@@ -50,7 +50,7 @@
// This string is used in two ways: // This string is used in two ways:
// 1) It is used to create a new .taskrc file, by copying it directly to disk. // 1) It is used to create a new .taskrc file, by copying it directly to disk.
// 2) It is parsed and used as default values for all Config.get calls. // 2) It is parsed and used as default values for all Config.get calls.
std::string Config::defaults = std::string Config::_defaults =
"# Taskwarrior program configuration file.\n" "# Taskwarrior program configuration file.\n"
"# For more documentation, see http://taskwarrior.org or try 'man task', 'man task-faq',\n" "# For more documentation, see http://taskwarrior.org or try 'man task', 'man task-faq',\n"
"# 'man task-tutorial', 'man task-color', 'man task-sync' or 'man taskrc'\n" "# 'man task-tutorial', 'man task-color', 'man task-sync' or 'man taskrc'\n"
@@ -469,7 +469,7 @@ std::string Config::defaults =
// //
// In all real use cases, Config::load is called. // In all real use cases, Config::load is called.
Config::Config () Config::Config ()
: original_file () : _original_file ()
{ {
} }
@@ -499,7 +499,7 @@ void Config::load (const std::string& file, int nest /* = 1 */)
if (nest == 1) if (nest == 1)
{ {
setDefaults (); setDefaults ();
original_file = File (file); _original_file = File (file);
} }
// Read the file, then parse the contents. // Read the file, then parse the contents.
@@ -554,10 +554,10 @@ void Config::parse (const std::string& input, int nest /* = 1 */)
if (included.readable ()) if (included.readable ())
this->load (included, nest + 1); this->load (included, nest + 1);
else else
throw format (STRING_CONFIG_READ_INCLUDE, included.data); throw format (STRING_CONFIG_READ_INCLUDE, included._data);
} }
else else
throw format (STRING_CONFIG_INCLUDE_PATH, included.data); throw format (STRING_CONFIG_INCLUDE_PATH, included._data);
} }
else else
throw format (STRING_CONFIG_BAD_ENTRY, line); throw format (STRING_CONFIG_BAD_ENTRY, line);
@@ -570,7 +570,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"); std::string::size_type loc = _defaults.find ("data.location=~/.task");
// loc+0^ +14^ +21^ // loc+0^ +14^ +21^
Date now; Date now;
@@ -580,7 +580,7 @@ void Config::createDefaultRC (const std::string& rc, const std::string& data)
<< " " << " "
<< now.toString ("m/d/Y H:N:S") << now.toString ("m/d/Y H:N:S")
<< "]\n" << "]\n"
<< defaults.substr (0, loc + 14) << _defaults.substr (0, loc + 14)
<< data << data
<< "\n\n# Color theme (uncomment one to use)\n" << "\n\n# Color theme (uncomment one to use)\n"
<< "#include /usr/local/share/doc/task/rc/light-16.theme\n" << "#include /usr/local/share/doc/task/rc/light-16.theme\n"
@@ -616,7 +616,7 @@ void Config::createDefaultData (const std::string& data)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Config::setDefaults () void Config::setDefaults ()
{ {
parse (defaults); parse (_defaults);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@@ -64,10 +64,10 @@ public:
std::string checkForDeprecatedColumns (); std::string checkForDeprecatedColumns ();
public: public:
File original_file; File _original_file;
private: private:
static std::string defaults; static std::string _defaults;
}; };
#endif #endif

View File

@@ -100,7 +100,7 @@ int Context::initialize (int argc, const char** argv)
std::string location; std::string location;
a3.get_data_location (location); a3.get_data_location (location);
data_dir = Directory (location); data_dir = Directory (location);
extension_dir = data_dir.data + "/extensions"; extension_dir = data_dir._data + "/extensions";
// Create missing config file and data directory, if necessary. // Create missing config file and data directory, if necessary.
createDefaultConfig (); createDefaultConfig ();
@@ -398,7 +398,7 @@ void Context::shadow ()
/* /*
// Determine if shadow file is enabled. // Determine if shadow file is enabled.
File shadowFile (config.get ("shadow.file")); File shadowFile (config.get ("shadow.file"));
if (shadowFile.data != "") if (shadowFile._data != "")
{ {
inShadow = true; // Prevents recursion in case shadow command writes. inShadow = true; // Prevents recursion in case shadow command writes.
@@ -436,21 +436,21 @@ void Context::shadow ()
// parse (); // parse ();
std::string result; std::string result;
(void)dispatch (result); (void)dispatch (result);
std::ofstream out (shadowFile.data.c_str ()); std::ofstream out (shadowFile._data.c_str ());
if (out.good ()) if (out.good ())
{ {
out << result; out << result;
out.close (); out.close ();
} }
else else
throw std::string ("Could not write file '") + shadowFile.data + "'"; throw std::string ("Could not write file '") + shadowFile._data + "'";
config.set ("detection", oldDetection); config.set ("detection", oldDetection);
config.set ("color", oldColor); config.set ("color", oldColor);
// Optionally display a notification that the shadow file was updated. // Optionally display a notification that the shadow file was updated.
if (config.getBoolean ("shadow.notify")) if (config.getBoolean ("shadow.notify"))
footnote (std::string ("[Shadow file '") + shadowFile.data + "' updated.]"); footnote (std::string ("[Shadow file '") + shadowFile._data + "' updated.]");
inShadow = false; inShadow = false;
} }
@@ -498,7 +498,7 @@ void Context::createDefaultConfig ()
// Do we need to create a default rc? // Do we need to create a default rc?
if (! rc_file.exists ()) if (! rc_file.exists ())
{ {
if (!confirm (format (STRING_CONTEXT_CREATE_RC, home_dir, rc_file.data))) if (!confirm (format (STRING_CONTEXT_CREATE_RC, home_dir, rc_file._data)))
throw std::string (STRING_CONTEXT_NEED_RC); throw std::string (STRING_CONTEXT_NEED_RC);
config.createDefaultRC (rc_file, data_dir); config.createDefaultRC (rc_file, data_dir);

View File

@@ -86,13 +86,13 @@ extern Context context;
// Defaults to "now". // Defaults to "now".
Date::Date () Date::Date ()
{ {
mT = time (NULL); _t = time (NULL);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Date::Date (const time_t t) Date::Date (const time_t t)
{ {
mT = t; _t = t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -105,7 +105,7 @@ Date::Date (const int m, const int d, const int y)
t.tm_mon = m - 1; t.tm_mon = m - 1;
t.tm_year = y - 1900; t.tm_year = y - 1900;
mT = mktime (&t); _t = mktime (&t);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -122,7 +122,7 @@ Date::Date (const int m, const int d, const int y,
t.tm_min = mi; t.tm_min = mi;
t.tm_sec = se; t.tm_sec = se;
mT = mktime (&t); _t = mktime (&t);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -138,11 +138,11 @@ Date::Date (const std::string& input, const std::string& format /* = "m/d/Y" */)
// Parse an ISO date. // Parse an ISO date.
Nibbler n (input); Nibbler n (input);
if (n.getDateISO (mT) && n.depleted ()) if (n.getDateISO (_t) && n.depleted ())
return; return;
// Parse a formatted date. // Parse a formatted date.
if (n.getDate (format, mT) && n.depleted ()) if (n.getDate (format, _t) && n.depleted ())
return; return;
throw ::format (STRING_DATE_INVALID_FORMAT, input, format); throw ::format (STRING_DATE_INVALID_FORMAT, input, format);
@@ -151,7 +151,7 @@ Date::Date (const std::string& input, const std::string& format /* = "m/d/Y" */)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Date::Date (const Date& rhs) Date::Date (const Date& rhs)
{ {
mT = rhs.mT; _t = rhs._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -162,14 +162,14 @@ Date::~Date ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
time_t Date::toEpoch () time_t Date::toEpoch ()
{ {
return mT; return _t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Date::toEpochString () std::string Date::toEpochString ()
{ {
std::stringstream epoch; std::stringstream epoch;
epoch << mT; epoch << _t;
return epoch.str (); return epoch.str ();
} }
@@ -177,7 +177,7 @@ std::string Date::toEpochString ()
// 19980119T070000Z = YYYYMMDDThhmmssZ // 19980119T070000Z = YYYYMMDDThhmmssZ
std::string Date::toISO () std::string Date::toISO ()
{ {
struct tm* t = gmtime (&mT); struct tm* t = gmtime (&_t);
std::stringstream iso; std::stringstream iso;
iso << std::setw (4) << std::setfill ('0') << t->tm_year + 1900 iso << std::setw (4) << std::setfill ('0') << t->tm_year + 1900
@@ -195,19 +195,19 @@ std::string Date::toISO ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
double Date::toJulian () double Date::toJulian ()
{ {
return (mT / 86400.0) + 2440587.5; return (_t / 86400.0) + 2440587.5;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Date::toEpoch (time_t& epoch) void Date::toEpoch (time_t& epoch)
{ {
epoch = mT; epoch = _t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Date::toMDY (int& m, int& d, int& y) void Date::toMDY (int& m, int& d, int& y)
{ {
struct tm* t = localtime (&mT); struct tm* t = localtime (&_t);
m = t->tm_mon + 1; m = t->tm_mon + 1;
d = t->tm_mday; d = t->tm_mday;
@@ -264,7 +264,7 @@ Date Date::startOfDay () const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Date Date::startOfWeek () const Date Date::startOfWeek () const
{ {
Date sow (mT); Date sow (_t);
sow -= (dayOfWeek () * 86400); sow -= (dayOfWeek () * 86400);
return Date (sow.month (), sow.day (), sow.year (), 0, 0, 0); return Date (sow.month (), sow.day (), sow.year (), 0, 0, 0);
} }
@@ -433,7 +433,7 @@ std::string Date::dayName (int dow)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int Date::weekOfYear (int weekStart) const int Date::weekOfYear (int weekStart) const
{ {
struct tm* t = localtime (&mT); struct tm* t = localtime (&_t);
char weekStr[3]; char weekStr[3];
if (weekStart == 0) if (weekStart == 0)
@@ -454,7 +454,7 @@ int Date::weekOfYear (int weekStart) const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int Date::dayOfWeek () const int Date::dayOfWeek () const
{ {
struct tm* t = localtime (&mT); struct tm* t = localtime (&_t);
return t->tm_wday; return t->tm_wday;
} }
@@ -477,7 +477,7 @@ int Date::dayOfWeek (const std::string& input)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int Date::dayOfYear () const int Date::dayOfYear () const
{ {
struct tm* t = localtime (&mT); struct tm* t = localtime (&_t);
return t->tm_yday + 1; return t->tm_yday + 1;
} }
@@ -563,79 +563,79 @@ time_t Date::easter (int year)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int Date::month () const int Date::month () const
{ {
struct tm* t = localtime (&mT); struct tm* t = localtime (&_t);
return t->tm_mon + 1; return t->tm_mon + 1;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int Date::day () const int Date::day () const
{ {
struct tm* t = localtime (&mT); struct tm* t = localtime (&_t);
return t->tm_mday; return t->tm_mday;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int Date::year () const int Date::year () const
{ {
struct tm* t = localtime (&mT); struct tm* t = localtime (&_t);
return t->tm_year + 1900; return t->tm_year + 1900;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int Date::hour () const int Date::hour () const
{ {
struct tm* t = localtime (&mT); struct tm* t = localtime (&_t);
return t->tm_hour; return t->tm_hour;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int Date::minute () const int Date::minute () const
{ {
struct tm* t = localtime (&mT); struct tm* t = localtime (&_t);
return t->tm_min; return t->tm_min;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int Date::second () const int Date::second () const
{ {
struct tm* t = localtime (&mT); struct tm* t = localtime (&_t);
return t->tm_sec; return t->tm_sec;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::operator== (const Date& rhs) bool Date::operator== (const Date& rhs)
{ {
return rhs.mT == mT; return rhs._t == _t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::operator!= (const Date& rhs) bool Date::operator!= (const Date& rhs)
{ {
return rhs.mT != mT; return rhs._t != _t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::operator< (const Date& rhs) bool Date::operator< (const Date& rhs)
{ {
return mT < rhs.mT; return _t < rhs._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::operator> (const Date& rhs) bool Date::operator> (const Date& rhs)
{ {
return mT > rhs.mT; return _t > rhs._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::operator<= (const Date& rhs) bool Date::operator<= (const Date& rhs)
{ {
return mT <= rhs.mT; return _t <= rhs._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Date::operator>= (const Date& rhs) bool Date::operator>= (const Date& rhs)
{ {
return mT >= rhs.mT; return _t >= rhs._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -683,33 +683,33 @@ bool Date::sameYear (const Date& rhs)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Date Date::operator- (const int delta) Date Date::operator- (const int delta)
{ {
return Date (mT - delta); return Date (_t - delta);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Date Date::operator+ (const int delta) Date Date::operator+ (const int delta)
{ {
return Date (mT + delta); return Date (_t + delta);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Date& Date::operator+= (const int delta) Date& Date::operator+= (const int delta)
{ {
mT += (time_t) delta; _t += (time_t) delta;
return *this; return *this;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Date& Date::operator-= (const int delta) Date& Date::operator-= (const int delta)
{ {
mT -= (time_t) delta; _t -= (time_t) delta;
return *this; return *this;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
time_t Date::operator- (const Date& rhs) time_t Date::operator- (const Date& rhs)
{ {
return mT - rhs.mT; return _t - rhs._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -723,7 +723,7 @@ void Date::operator-- ()
hour (), hour (),
minute (), minute (),
second ()); second ());
mT = yesterday.mT; _t = yesterday._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -737,7 +737,7 @@ void Date::operator-- (int)
hour (), hour (),
minute (), minute (),
second ()); second ());
mT = yesterday.mT; _t = yesterday._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -751,7 +751,7 @@ void Date::operator++ ()
hour (), hour (),
minute (), minute (),
second ()); second ());
mT = tomorrow.mT; _t = tomorrow._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -765,7 +765,7 @@ void Date::operator++ (int)
hour (), hour (),
minute (), minute (),
second ()); second ());
mT = tomorrow.mT; _t = tomorrow._t;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -775,7 +775,7 @@ bool Date::isEpoch (const std::string& input)
input.length () > 8 && input.length () > 8 &&
input.length () <= 10 ) input.length () <= 10 )
{ {
mT = (time_t) atoi (input.c_str ()); _t = (time_t) atoi (input.c_str ());
return true; return true;
} }
@@ -783,7 +783,7 @@ bool Date::isEpoch (const std::string& input)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// If the input string looks like a relative date, determine that date, set mT // If the input string looks like a relative date, determine that date, set _t
// and return true. // and return true.
// //
// What is a relative date? All of the following should be recognizable, and // What is a relative date? All of the following should be recognizable, and
@@ -844,7 +844,7 @@ bool Date::isRelativeDate (const std::string& input)
today.toMDY (m, d, y); today.toMDY (m, d, y);
Date then (m, d, y); Date then (m, d, y);
mT = then.mT; _t = then._t;
return true; return true;
} }
else if (found == "today") else if (found == "today")
@@ -852,7 +852,7 @@ bool Date::isRelativeDate (const std::string& input)
Date then (today.month (), Date then (today.month (),
today.day (), today.day (),
today.year ()); today.year ());
mT = then.mT; _t = then._t;
return true; return true;
} }
else if (found == "tomorrow") else if (found == "tomorrow")
@@ -860,7 +860,7 @@ bool Date::isRelativeDate (const std::string& input)
Date then (today.month (), Date then (today.month (),
today.day (), today.day (),
today.year ()); today.year ());
mT = then.mT + 86400; _t = then._t + 86400;
return true; return true;
} }
else if (found == "yesterday") else if (found == "yesterday")
@@ -868,7 +868,7 @@ bool Date::isRelativeDate (const std::string& input)
Date then (today.month (), Date then (today.month (),
today.day (), today.day (),
today.year ()); today.year ());
mT = then.mT - 86400; _t = then._t - 86400;
return true; return true;
} }
else if (found == "eom") else if (found == "eom")
@@ -876,7 +876,7 @@ bool Date::isRelativeDate (const std::string& input)
Date then (today.month (), Date then (today.month (),
daysInMonth (today.month (), today.year ()), daysInMonth (today.month (), today.year ()),
today.year ()); today.year ());
mT = then.mT; _t = then._t;
return true; return true;
} }
else if (found == "eoq") else if (found == "eoq")
@@ -895,13 +895,13 @@ bool Date::isRelativeDate (const std::string& input)
Date then (q, Date then (q,
Date::daysInMonth (q, y), Date::daysInMonth (q, y),
y); y);
mT = then.mT; _t = then._t;
return true; return true;
} }
else if (found == "eoy") else if (found == "eoy")
{ {
Date then (12, 31, today.year ()); Date then (12, 31, today.year ());
mT = then.mT; _t = then._t;
return true; return true;
} }
else if (found == "som") else if (found == "som")
@@ -914,7 +914,7 @@ bool Date::isRelativeDate (const std::string& input)
y++; y++;
} }
Date then (m, 1, y); Date then (m, 1, y);
mT = then.mT; _t = then._t;
return true; return true;
} }
else if (found == "soq") else if (found == "soq")
@@ -933,43 +933,43 @@ bool Date::isRelativeDate (const std::string& input)
Date then (q, Date then (q,
1, 1,
y); y);
mT = then.mT; _t = then._t;
return true; return true;
} }
else if (found == "soy") else if (found == "soy")
{ {
Date then (1, 1, today.year () + 1); Date then (1, 1, today.year () + 1);
mT = then.mT; _t = then._t;
return true; return true;
} }
else if (found == "goodfriday") else if (found == "goodfriday")
{ {
Date then (Date::easter(today.year())); Date then (Date::easter(today.year()));
mT = then.mT - 86400*2; _t = then._t - 86400*2;
return true; return true;
} }
else if (found == "easter") else if (found == "easter")
{ {
Date then (Date::easter(today.year())); Date then (Date::easter(today.year()));
mT = then.mT; _t = then._t;
return true; return true;
} }
else if (found == "eastermonday") else if (found == "eastermonday")
{ {
Date then (Date::easter(today.year())); Date then (Date::easter(today.year()));
mT = then.mT + 86400; _t = then._t + 86400;
return true; return true;
} }
else if (found == "ascension") else if (found == "ascension")
{ {
Date then (Date::easter(today.year())); Date then (Date::easter(today.year()));
mT = then.mT + 86400*39; _t = then._t + 86400*39;
return true; return true;
} }
else if (found == "pentecost") else if (found == "pentecost")
{ {
Date then (Date::easter(today.year())); Date then (Date::easter(today.year()));
mT = then.mT + 86400*49; _t = then._t + 86400*49;
return true; return true;
} }
else if (found == "midsommar") else if (found == "midsommar")
@@ -979,7 +979,7 @@ bool Date::isRelativeDate (const std::string& input)
Date then (6, midsommar, today.year ()); Date then (6, midsommar, today.year ());
if (6 == then.dayOfWeek ()) if (6 == then.dayOfWeek ())
{ {
mT = then.mT; _t = then._t;
return true; return true;
} }
} }
@@ -991,20 +991,20 @@ bool Date::isRelativeDate (const std::string& input)
Date then (6, midsommar, today.year ()); Date then (6, midsommar, today.year ());
if (5 == then.dayOfWeek ()) if (5 == then.dayOfWeek ())
{ {
mT = then.mT; _t = then._t;
return true; return true;
} }
} }
} }
else if (found == "now") else if (found == "now")
{ {
mT = time (NULL); _t = time (NULL);
return true; return true;
} }
else if (found == "later" || found == "someday") else if (found == "later" || found == "someday")
{ {
Date then (1, 18, 2038); Date then (1, 18, 2038);
mT = then.mT; _t = then._t;
return true; return true;
} }
} }
@@ -1044,7 +1044,7 @@ bool Date::isRelativeDate (const std::string& input)
number <= Date::daysInMonth (m, y)) number <= Date::daysInMonth (m, y))
{ {
Date then (m, number, y); Date then (m, number, y);
mT = then.mT; _t = then._t;
return true; return true;
} }
@@ -1061,7 +1061,7 @@ bool Date::isRelativeDate (const std::string& input)
while (number > Date::daysInMonth (m, y)); while (number > Date::daysInMonth (m, y));
Date then (m, number, y); Date then (m, number, y);
mT = then.mT; _t = then._t;
return true; return true;
} }
} }

View File

@@ -114,7 +114,7 @@ private:
bool isRelativeDate (const std::string&); bool isRelativeDate (const std::string&);
protected: protected:
time_t mT; time_t _t;
}; };
#endif #endif

View File

@@ -83,13 +83,13 @@ Directory& Directory::operator= (const Directory& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Directory::create () bool Directory::create ()
{ {
return mkdir (data.c_str (), 0755) == 0 ? true : false; return mkdir (_data.c_str (), 0755) == 0 ? true : false;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Directory::remove () bool Directory::remove ()
{ {
return remove_directory (data); return remove_directory (_data);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -130,7 +130,7 @@ bool Directory::remove_directory (const std::string& dir)
std::vector <std::string> Directory::list () std::vector <std::string> Directory::list ()
{ {
std::vector <std::string> files; std::vector <std::string> files;
list (data, files, false); list (_data, files, false);
return files; return files;
} }
@@ -138,7 +138,7 @@ std::vector <std::string> Directory::list ()
std::vector <std::string> Directory::listRecursive () std::vector <std::string> Directory::listRecursive ()
{ {
std::vector <std::string> files; std::vector <std::string> files;
list (data, files, true); list (_data, files, true);
return files; return files;
} }

View File

@@ -101,16 +101,16 @@ extern Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Duration::Duration () Duration::Duration ()
: mSecs (0) : _secs (0)
, mNegative (false) , _negative (false)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Duration::Duration (const Duration& other) Duration::Duration (const Duration& other)
{ {
mSecs = other.mSecs; _secs = other._secs;
mNegative = other.mNegative; _negative = other._negative;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -118,25 +118,25 @@ Duration::Duration (time_t input)
{ {
if (input < 0) if (input < 0)
{ {
mSecs = -input; _secs = -input;
mNegative = true; _negative = true;
} }
else else
{ {
mSecs = input; _secs = input;
mNegative = false; _negative = false;
} }
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Duration::Duration (const std::string& input) Duration::Duration (const std::string& input)
: mSecs (0) : _secs (0)
, mNegative (false) , _negative (false)
{ {
if (digitsOnly (input)) if (digitsOnly (input))
{ {
mSecs = (time_t) strtol (input.c_str (), NULL, 10); _secs = (time_t) strtol (input.c_str (), NULL, 10);
mNegative = false; _negative = false;
} }
else else
parse (input); parse (input);
@@ -145,14 +145,14 @@ Duration::Duration (const std::string& input)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Duration::operator time_t () const Duration::operator time_t () const
{ {
return mSecs; return _secs;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Duration::operator std::string () const Duration::operator std::string () const
{ {
std::stringstream s; std::stringstream s;
s << (mNegative ? - (long) mSecs : (long) mSecs); s << (_negative ? - (long) _secs : (long) _secs);
return s.str (); return s.str ();
} }
@@ -161,8 +161,8 @@ Duration& Duration::operator= (const Duration& other)
{ {
if (this != &other) if (this != &other)
{ {
mSecs = other.mSecs; _secs = other._secs;
mNegative = other.mNegative; _negative = other._negative;
} }
return *this; return *this;
@@ -171,14 +171,14 @@ Duration& Duration::operator= (const Duration& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Duration Duration::operator- (const Duration& other) Duration Duration::operator- (const Duration& other)
{ {
int left = mSecs * ( mNegative ? -1 : 1); int left = _secs * ( _negative ? -1 : 1);
int right = other.mSecs * (other.mNegative ? -1 : 1); int right = other._secs * (other._negative ? -1 : 1);
left -= right; left -= right;
Duration result; Duration result;
result.mSecs = abs (left); result._secs = abs (left);
result.mNegative = left < 0; result._negative = left < 0;
return result; return result;
} }
@@ -186,14 +186,14 @@ Duration Duration::operator- (const Duration& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Duration Duration::operator+ (const Duration& other) Duration Duration::operator+ (const Duration& other)
{ {
int left = mSecs * ( mNegative ? -1 : 1); int left = _secs * ( _negative ? -1 : 1);
int right = other.mSecs * (other.mNegative ? -1 : 1); int right = other._secs * (other._negative ? -1 : 1);
left += right; left += right;
Duration result; Duration result;
result.mSecs = abs (left); result._secs = abs (left);
result.mNegative = left < 0; result._negative = left < 0;
return result; return result;
} }
@@ -201,13 +201,13 @@ Duration Duration::operator+ (const Duration& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Duration& Duration::operator-= (const Duration& other) Duration& Duration::operator-= (const Duration& other)
{ {
int left = mSecs * ( mNegative ? -1 : 1); int left = _secs * ( _negative ? -1 : 1);
int right = other.mSecs * (other.mNegative ? -1 : 1); int right = other._secs * (other._negative ? -1 : 1);
left -= right; left -= right;
mSecs = abs (left); _secs = abs (left);
mNegative = left < 0; _negative = left < 0;
return *this; return *this;
} }
@@ -215,13 +215,13 @@ Duration& Duration::operator-= (const Duration& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Duration& Duration::operator+= (const Duration& other) Duration& Duration::operator+= (const Duration& other)
{ {
int left = mSecs * ( mNegative ? -1 : 1); int left = _secs * ( _negative ? -1 : 1);
int right = other.mSecs * (other.mNegative ? -1 : 1); int right = other._secs * (other._negative ? -1 : 1);
left += right; left += right;
mSecs = abs (left); _secs = abs (left);
mNegative = left < 0; _negative = left < 0;
return *this; return *this;
} }
@@ -230,34 +230,34 @@ Duration& Duration::operator+= (const Duration& other)
std::string Duration::format () const std::string Duration::format () const
{ {
char formatted[24]; char formatted[24];
float days = (float) mSecs / 86400.0; float days = (float) _secs / 86400.0;
if (mSecs >= 86400 * 365) if (_secs >= 86400 * 365)
sprintf (formatted, "%s%.1f yrs", (mNegative ? "-" : ""), (days / 365)); sprintf (formatted, "%s%.1f yrs", (_negative ? "-" : ""), (days / 365));
else if (mSecs > 86400 * 84) else if (_secs > 86400 * 84)
sprintf (formatted, "%s%1d mth%s", sprintf (formatted, "%s%1d mth%s",
(mNegative ? "-" : ""), (int) (float) (days / 30.6), (_negative ? "-" : ""), (int) (float) (days / 30.6),
((int) (float) (days / 30.6) == 1 ? "" : "s")); ((int) (float) (days / 30.6) == 1 ? "" : "s"));
else if (mSecs > 86400 * 13) else if (_secs > 86400 * 13)
sprintf (formatted, "%s%d wk%s", sprintf (formatted, "%s%d wk%s",
(mNegative ? "-" : ""), (int) (float) (days / 7.0), (_negative ? "-" : ""), (int) (float) (days / 7.0),
((int) (float) (days / 7.0) == 1 ? "" : "s")); ((int) (float) (days / 7.0) == 1 ? "" : "s"));
else if (mSecs >= 86400) else if (_secs >= 86400)
sprintf (formatted, "%s%d day%s", sprintf (formatted, "%s%d day%s",
(mNegative ? "-" : ""), (int) days, (_negative ? "-" : ""), (int) days,
((int) days == 1 ? "" : "s")); ((int) days == 1 ? "" : "s"));
else if (mSecs >= 3600) else if (_secs >= 3600)
sprintf (formatted, "%s%d hr%s", sprintf (formatted, "%s%d hr%s",
(mNegative ? "-" : ""), (int) (float) (mSecs / 3600), (_negative ? "-" : ""), (int) (float) (_secs / 3600),
((int) (float) (mSecs / 3600) == 1 ? "" : "s")); ((int) (float) (_secs / 3600) == 1 ? "" : "s"));
else if (mSecs >= 60) else if (_secs >= 60)
sprintf (formatted, "%s%d min%s", sprintf (formatted, "%s%d min%s",
(mNegative ? "-" : ""), (int) (float) (mSecs / 60), (_negative ? "-" : ""), (int) (float) (_secs / 60),
((int) (float) (mSecs / 60) == 1 ? "" : "s")); ((int) (float) (_secs / 60) == 1 ? "" : "s"));
else if (mSecs >= 1) else if (_secs >= 1)
sprintf (formatted, "%s%d sec%s", sprintf (formatted, "%s%d sec%s",
(mNegative ? "-" : ""), (int) mSecs, (_negative ? "-" : ""), (int) _secs,
((int) mSecs == 1 ? "" : "s")); ((int) _secs == 1 ? "" : "s"));
else else
strcpy (formatted, "-"); // no i18n strcpy (formatted, "-"); // no i18n
@@ -268,15 +268,15 @@ std::string Duration::format () const
std::string Duration::formatCompact () const std::string Duration::formatCompact () const
{ {
char formatted[24]; char formatted[24];
float days = (float) mSecs / 86400.0; float days = (float) _secs / 86400.0;
if (mSecs >= 86400 * 365) sprintf (formatted, "%s%.1fy", (mNegative ? "-" : ""), (days / 365)); if (_secs >= 86400 * 365) sprintf (formatted, "%s%.1fy", (_negative ? "-" : ""), (days / 365));
else if (mSecs >= 86400 * 84) sprintf (formatted, "%s%1dmo", (mNegative ? "-" : ""), (int) (float) (days / 30.6)); else if (_secs >= 86400 * 84) sprintf (formatted, "%s%1dmo", (_negative ? "-" : ""), (int) (float) (days / 30.6));
else if (mSecs >= 86400 * 13) sprintf (formatted, "%s%dwk", (mNegative ? "-" : ""), (int) (float) (days / 7.0)); else if (_secs >= 86400 * 13) sprintf (formatted, "%s%dwk", (_negative ? "-" : ""), (int) (float) (days / 7.0));
else if (mSecs >= 86400) sprintf (formatted, "%s%dd", (mNegative ? "-" : ""), (int) days); else if (_secs >= 86400) sprintf (formatted, "%s%dd", (_negative ? "-" : ""), (int) days);
else if (mSecs >= 3600) sprintf (formatted, "%s%dh", (mNegative ? "-" : ""), (int) (float) (mSecs / 3600)); else if (_secs >= 3600) sprintf (formatted, "%s%dh", (_negative ? "-" : ""), (int) (float) (_secs / 3600));
else if (mSecs >= 60) sprintf (formatted, "%s%dm", (mNegative ? "-" : ""), (int) (float) (mSecs / 60)); else if (_secs >= 60) sprintf (formatted, "%s%dm", (_negative ? "-" : ""), (int) (float) (_secs / 60));
else if (mSecs >= 1) sprintf (formatted, "%s%ds", (mNegative ? "-" : ""), (int) mSecs); else if (_secs >= 1) sprintf (formatted, "%s%ds", (_negative ? "-" : ""), (int) _secs);
else strcpy (formatted, "-"); else strcpy (formatted, "-");
return std::string (formatted); return std::string (formatted);
@@ -287,13 +287,13 @@ std::string Duration::formatPrecise () const
{ {
char formatted[24]; char formatted[24];
int days = mSecs / 86400; int days = _secs / 86400;
int hours = (mSecs % 86400) / 3600; int hours = (_secs % 86400) / 3600;
int minutes = (mSecs % 3600) / 60; int minutes = (_secs % 3600) / 60;
int seconds = mSecs % 60; int seconds = _secs % 60;
if (days > 0) sprintf (formatted, "%s%dd %d:%02d:%02d", (mNegative ? "-" : ""), days, hours, minutes, seconds); if (days > 0) sprintf (formatted, "%s%dd %d:%02d:%02d", (_negative ? "-" : ""), days, hours, minutes, seconds);
else sprintf (formatted, "%s%d:%02d:%02d", (mNegative ? "-" : ""), hours, minutes, seconds); else sprintf (formatted, "%s%d:%02d:%02d", (_negative ? "-" : ""), hours, minutes, seconds);
return std::string (formatted); return std::string (formatted);
} }
@@ -301,8 +301,8 @@ std::string Duration::formatPrecise () const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Duration::operator< (const Duration& other) bool Duration::operator< (const Duration& other)
{ {
long left = (long) ( mNegative ? -mSecs : mSecs); long left = (long) ( _negative ? -_secs : _secs);
long right = (long) (other.mNegative ? -other.mSecs : other.mSecs); long right = (long) (other._negative ? -other._secs : other._secs);
return left < right; return left < right;
} }
@@ -310,8 +310,8 @@ bool Duration::operator< (const Duration& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Duration::operator<= (const Duration& other) bool Duration::operator<= (const Duration& other)
{ {
long left = (long) ( mNegative ? -mSecs : mSecs); long left = (long) ( _negative ? -_secs : _secs);
long right = (long) (other.mNegative ? -other.mSecs : other.mSecs); long right = (long) (other._negative ? -other._secs : other._secs);
return left <= right; return left <= right;
} }
@@ -319,8 +319,8 @@ bool Duration::operator<= (const Duration& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Duration::operator> (const Duration& other) bool Duration::operator> (const Duration& other)
{ {
long left = (long) ( mNegative ? -mSecs : mSecs); long left = (long) ( _negative ? -_secs : _secs);
long right = (long) (other.mNegative ? -other.mSecs : other.mSecs); long right = (long) (other._negative ? -other._secs : other._secs);
return left > right; return left > right;
} }
@@ -328,8 +328,8 @@ bool Duration::operator> (const Duration& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Duration::operator>= (const Duration& other) bool Duration::operator>= (const Duration& other)
{ {
long left = (long) ( mNegative ? -mSecs : mSecs); long left = (long) ( _negative ? -_secs : _secs);
long right = (long) (other.mNegative ? -other.mSecs : other.mSecs); long right = (long) (other._negative ? -other._secs : other._secs);
return left >= right; return left >= right;
} }
@@ -342,7 +342,7 @@ Duration::~Duration ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Duration::negative () const bool Duration::negative () const
{ {
return mNegative; return _negative;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -394,11 +394,11 @@ void Duration::parse (const std::string& input)
if (value < 0.0) if (value < 0.0)
{ {
mNegative = true; _negative = true;
value = -value; value = -value;
} }
else else
mNegative = false; _negative = false;
std::string units; std::string units;
n.getUntilEOS (units); n.getUntilEOS (units);
@@ -408,7 +408,7 @@ void Duration::parse (const std::string& input)
for (unsigned int i = 0; i < NUM_DURATIONS; ++i) for (unsigned int i = 0; i < NUM_DURATIONS; ++i)
supported.push_back (durations[i]); supported.push_back (durations[i]);
mSecs = 0; _secs = 0;
std::vector <std::string> matches; std::vector <std::string> matches;
if (autoComplete (units, if (autoComplete (units,
supported, supported,
@@ -417,73 +417,73 @@ void Duration::parse (const std::string& input)
{ {
std::string match = matches[0]; std::string match = matches[0];
if (match == "biannual") mSecs = (int) (value * 86400 * 730); if (match == "biannual") _secs = (int) (value * 86400 * 730);
else if (match == "biyearly") mSecs = (int) (value * 86400 * 730); else if (match == "biyearly") _secs = (int) (value * 86400 * 730);
else if (match == "yearly") mSecs = (int) (value * 86400 * 365); else if (match == "yearly") _secs = (int) (value * 86400 * 365);
else if (match == "annual") mSecs = (int) (value * 86400 * 365); else if (match == "annual") _secs = (int) (value * 86400 * 365);
else if (match == "years") mSecs = (int) (value * 86400 * 365); else if (match == "years") _secs = (int) (value * 86400 * 365);
else if (match == "year") mSecs = (int) (value * 86400 * 365); else if (match == "year") _secs = (int) (value * 86400 * 365);
else if (match == "yrs") mSecs = (int) (value * 86400 * 365); else if (match == "yrs") _secs = (int) (value * 86400 * 365);
else if (match == "yr") mSecs = (int) (value * 86400 * 365); else if (match == "yr") _secs = (int) (value * 86400 * 365);
else if (match == "y") mSecs = (int) (value * 86400 * 365); else if (match == "y") _secs = (int) (value * 86400 * 365);
else if (match == "semiannual") mSecs = (int) (value * 86400 * 183); else if (match == "semiannual") _secs = (int) (value * 86400 * 183);
else if (match == "bimonthly") mSecs = (int) (value * 86400 * 61); else if (match == "bimonthly") _secs = (int) (value * 86400 * 61);
else if (match == "quarterly") mSecs = (int) (value * 86400 * 91); else if (match == "quarterly") _secs = (int) (value * 86400 * 91);
else if (match == "quarters") mSecs = (int) (value * 86400 * 91); else if (match == "quarters") _secs = (int) (value * 86400 * 91);
else if (match == "qrtrs") mSecs = (int) (value * 86400 * 91); else if (match == "qrtrs") _secs = (int) (value * 86400 * 91);
else if (match == "qtrs") mSecs = (int) (value * 86400 * 91); else if (match == "qtrs") _secs = (int) (value * 86400 * 91);
else if (match == "qtr") mSecs = (int) (value * 86400 * 91); else if (match == "qtr") _secs = (int) (value * 86400 * 91);
else if (match == "q") mSecs = (int) (value * 86400 * 91); else if (match == "q") _secs = (int) (value * 86400 * 91);
else if (match == "monthly") mSecs = (int) (value * 86400 * 30); else if (match == "monthly") _secs = (int) (value * 86400 * 30);
else if (match == "month") mSecs = (int) (value * 86400 * 30); else if (match == "month") _secs = (int) (value * 86400 * 30);
else if (match == "months") mSecs = (int) (value * 86400 * 30); else if (match == "months") _secs = (int) (value * 86400 * 30);
else if (match == "mnths") mSecs = (int) (value * 86400 * 30); else if (match == "mnths") _secs = (int) (value * 86400 * 30);
else if (match == "mos") mSecs = (int) (value * 86400 * 30); else if (match == "mos") _secs = (int) (value * 86400 * 30);
else if (match == "mo") mSecs = (int) (value * 86400 * 30); else if (match == "mo") _secs = (int) (value * 86400 * 30);
else if (match == "mths") mSecs = (int) (value * 86400 * 30); else if (match == "mths") _secs = (int) (value * 86400 * 30);
else if (match == "mth") mSecs = (int) (value * 86400 * 30); else if (match == "mth") _secs = (int) (value * 86400 * 30);
else if (match == "m") mSecs = (int) (value * 86400 * 30); else if (match == "m") _secs = (int) (value * 86400 * 30);
else if (match == "biweekly") mSecs = (int) (value * 86400 * 14); else if (match == "biweekly") _secs = (int) (value * 86400 * 14);
else if (match == "fortnight") mSecs = (int) (value * 86400 * 14); else if (match == "fortnight") _secs = (int) (value * 86400 * 14);
else if (match == "weekly") mSecs = (int) (value * 86400 * 7); else if (match == "weekly") _secs = (int) (value * 86400 * 7);
else if (match == "sennight") mSecs = (int) (value * 86400 * 7); else if (match == "sennight") _secs = (int) (value * 86400 * 7);
else if (match == "weeks") mSecs = (int) (value * 86400 * 7); else if (match == "weeks") _secs = (int) (value * 86400 * 7);
else if (match == "week") mSecs = (int) (value * 86400 * 7); else if (match == "week") _secs = (int) (value * 86400 * 7);
else if (match == "wks") mSecs = (int) (value * 86400 * 7); else if (match == "wks") _secs = (int) (value * 86400 * 7);
else if (match == "wk") mSecs = (int) (value * 86400 * 7); else if (match == "wk") _secs = (int) (value * 86400 * 7);
else if (match == "w") mSecs = (int) (value * 86400 * 7); else if (match == "w") _secs = (int) (value * 86400 * 7);
else if (match == "daily") mSecs = (int) (value * 86400 * 1); else if (match == "daily") _secs = (int) (value * 86400 * 1);
else if (match == "day") mSecs = (int) (value * 86400 * 1); else if (match == "day") _secs = (int) (value * 86400 * 1);
else if (match == "weekdays") mSecs = (int) (value * 86400 * 1); else if (match == "weekdays") _secs = (int) (value * 86400 * 1);
else if (match == "days") mSecs = (int) (value * 86400 * 1); else if (match == "days") _secs = (int) (value * 86400 * 1);
else if (match == "d") mSecs = (int) (value * 86400 * 1); else if (match == "d") _secs = (int) (value * 86400 * 1);
else if (match == "hours") mSecs = (int) (value * 3600); else if (match == "hours") _secs = (int) (value * 3600);
else if (match == "hour") mSecs = (int) (value * 3600); else if (match == "hour") _secs = (int) (value * 3600);
else if (match == "hrs") mSecs = (int) (value * 3600); else if (match == "hrs") _secs = (int) (value * 3600);
else if (match == "hr") mSecs = (int) (value * 3600); else if (match == "hr") _secs = (int) (value * 3600);
else if (match == "h") mSecs = (int) (value * 3600); else if (match == "h") _secs = (int) (value * 3600);
else if (match == "minutes") mSecs = (int) (value * 60); else if (match == "minutes") _secs = (int) (value * 60);
else if (match == "mins") mSecs = (int) (value * 60); else if (match == "mins") _secs = (int) (value * 60);
else if (match == "min") mSecs = (int) (value * 60); else if (match == "min") _secs = (int) (value * 60);
else if (match == "seconds") mSecs = (int) value; else if (match == "seconds") _secs = (int) value;
else if (match == "secs") mSecs = (int) value; else if (match == "secs") _secs = (int) value;
else if (match == "sec") mSecs = (int) value; else if (match == "sec") _secs = (int) value;
else if (match == "s") mSecs = (int) value; else if (match == "s") _secs = (int) value;
else if (match == "-") mSecs = 0; else if (match == "-") _secs = 0;
} }
if (mSecs == 0) if (_secs == 0)
throw ::format (STRING_DURATION_UNRECOGNIZED, input); throw ::format (STRING_DURATION_UNRECOGNIZED, input);
} }

View File

@@ -64,8 +64,8 @@ public:
static const std::vector <std::string> get_units (); static const std::vector <std::string> get_units ();
protected: protected:
time_t mSecs; time_t _secs;
bool mNegative; bool _negative;
}; };
#endif #endif

View File

@@ -40,43 +40,43 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
File::File () File::File ()
: Path::Path () : Path::Path ()
, fh (NULL) , _fh (NULL)
, h (-1) , _h (-1)
, locked (false) , _locked (false)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
File::File (const Path& other) File::File (const Path& other)
: Path::Path (other) : Path::Path (other)
, fh (NULL) , _fh (NULL)
, h (-1) , _h (-1)
, locked (false) , _locked (false)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
File::File (const File& other) File::File (const File& other)
: Path::Path (other) : Path::Path (other)
, fh (NULL) , _fh (NULL)
, h (-1) , _h (-1)
, locked (false) , _locked (false)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
File::File (const std::string& in) File::File (const std::string& in)
: Path::Path (in) : Path::Path (in)
, fh (NULL) , _fh (NULL)
, h (-1) , _h (-1)
, locked (false) , _locked (false)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
File::~File () File::~File ()
{ {
if (fh) if (_fh)
close (); close ();
} }
@@ -86,7 +86,7 @@ File& File::operator= (const File& other)
if (this != &other) if (this != &other)
Path::operator= (other); Path::operator= (other);
locked = false; _locked = false;
return *this; return *this;
} }
@@ -105,26 +105,26 @@ bool File::create ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool File::remove () bool File::remove ()
{ {
return unlink (data.c_str ()) == 0 ? true : false; return unlink (_data.c_str ()) == 0 ? true : false;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool File::open () bool File::open ()
{ {
if (data != "") if (_data != "")
{ {
if (! fh) if (! _fh)
{ {
bool already_exists = exists (); bool already_exists = exists ();
if (already_exists) if (already_exists)
if (!readable () || !writable ()) if (!readable () || !writable ())
throw std::string (format (STRING_FILE_PERMS, data)); throw std::string (format (STRING_FILE_PERMS, _data));
fh = fopen (data.c_str (), (already_exists ? "r+" : "w+")); _fh = fopen (_data.c_str (), (already_exists ? "r+" : "w+"));
if (fh) if (_fh)
{ {
h = fileno (fh); _h = fileno (_fh);
locked = false; _locked = false;
return true; return true;
} }
} }
@@ -144,46 +144,46 @@ bool File::openAndLock ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void File::close () void File::close ()
{ {
if (fh) if (_fh)
{ {
fclose (fh); fclose (_fh);
fh = NULL; _fh = NULL;
h = -1; _h = -1;
locked = false; _locked = false;
} }
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool File::lock () bool File::lock ()
{ {
if (fh && h != -1) if (_fh && _h != -1)
{ {
// Try three times before failing. // Try three times before failing.
int retry = 0; int retry = 0;
while (flock (h, LOCK_NB | LOCK_EX) && ++retry <= 3) while (flock (_h, LOCK_NB | LOCK_EX) && ++retry <= 3)
; ;
if (retry <= 3) if (retry <= 3)
{ {
locked = true; _locked = true;
return true; return true;
} }
} }
locked = false; _locked = false;
return false; return false;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool File::waitForLock () bool File::waitForLock ()
{ {
if (locked) if (_locked)
return true; return true;
if (fh && h != -1) if (_fh && _h != -1)
if (flock (h, LOCK_EX) == 0) if (flock (_h, LOCK_EX) == 0)
{ {
locked = true; _locked = true;
return true; return true;
} }
@@ -196,7 +196,7 @@ void File::read (std::string& contents)
{ {
contents = ""; contents = "";
std::ifstream in (data.c_str ()); std::ifstream in (_data.c_str ());
if (in.good ()) if (in.good ())
{ {
std::string line; std::string line;
@@ -213,7 +213,7 @@ void File::read (std::vector <std::string>& contents)
{ {
contents.clear (); contents.clear ();
std::ifstream in (data.c_str ()); std::ifstream in (_data.c_str ());
if (in.good ()) if (in.good ())
{ {
std::string line; std::string line;
@@ -228,25 +228,25 @@ void File::read (std::vector <std::string>& contents)
// Opens if necessary. // Opens if necessary.
void File::write (const std::string& line) void File::write (const std::string& line)
{ {
if (!fh) if (!_fh)
open (); open ();
if (fh) if (_fh)
fputs (line.c_str (), fh); fputs (line.c_str (), _fh);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Opens if necessary. // Opens if necessary.
void File::write (const std::vector <std::string>& lines) void File::write (const std::vector <std::string>& lines)
{ {
if (!fh) if (!_fh)
open (); open ();
if (fh) if (_fh)
{ {
std::vector <std::string>::const_iterator it; std::vector <std::string>::const_iterator it;
for (it = lines.begin (); it != lines.end (); ++it) for (it = lines.begin (); it != lines.end (); ++it)
fputs (it->c_str (), fh); fputs (it->c_str (), _fh);
} }
} }
@@ -254,13 +254,13 @@ void File::write (const std::vector <std::string>& lines)
// Opens if necessary. // Opens if necessary.
void File::append (const std::string& line) void File::append (const std::string& line)
{ {
if (!fh) if (!_fh)
open (); open ();
if (fh) if (_fh)
{ {
fseek (fh, 0, SEEK_END); fseek (_fh, 0, SEEK_END);
fputs (line.c_str (), fh); fputs (line.c_str (), _fh);
} }
} }
@@ -268,26 +268,26 @@ void File::append (const std::string& line)
// Opens if necessary. // Opens if necessary.
void File::append (const std::vector <std::string>& lines) void File::append (const std::vector <std::string>& lines)
{ {
if (!fh) if (!_fh)
open (); open ();
if (fh) if (_fh)
{ {
fseek (fh, 0, SEEK_END); fseek (_fh, 0, SEEK_END);
std::vector <std::string>::const_iterator it; std::vector <std::string>::const_iterator it;
for (it = lines.begin (); it != lines.end (); ++it) for (it = lines.begin (); it != lines.end (); ++it)
fputs (((*it) + "\n").c_str (), fh); fputs (((*it) + "\n").c_str (), _fh);
} }
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void File::truncate () void File::truncate ()
{ {
if (!fh) if (!_fh)
open (); open ();
if (fh) if (_fh)
ftruncate (h, 0); ftruncate (_h, 0);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -309,7 +309,7 @@ void File::truncate ()
mode_t File::mode () mode_t File::mode ()
{ {
struct stat s; struct stat s;
if (!stat (data.c_str (), &s)) if (!stat (_data.c_str (), &s))
return s.st_mode; return s.st_mode;
return 0; return 0;
@@ -319,7 +319,7 @@ mode_t File::mode ()
size_t File::size () const size_t File::size () const
{ {
struct stat s; struct stat s;
if (!stat (data.c_str (), &s)) if (!stat (_data.c_str (), &s))
return s.st_size; return s.st_size;
return 0; return 0;
@@ -329,7 +329,7 @@ size_t File::size () const
time_t File::mtime () const time_t File::mtime () const
{ {
struct stat s; struct stat s;
if (!stat (data.c_str (), &s)) if (!stat (_data.c_str (), &s))
return s.st_mtime; return s.st_mtime;
return 0; return 0;

View File

@@ -82,9 +82,9 @@ public:
static bool remove (const std::string&); static bool remove (const std::string&);
private: private:
FILE* fh; FILE* _fh;
int h; int _h;
bool locked; bool _locked;
}; };
#endif #endif

View File

@@ -39,26 +39,26 @@ extern Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Hook::Hook () Hook::Hook ()
: event ("") : _event ("")
, file ("") , _file ("")
, function ("") , _function ("")
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Hook::Hook (const std::string& e, const std::string& f, const std::string& fn) Hook::Hook (const std::string& e, const std::string& f, const std::string& fn)
: event (e) : _event (e)
, file (f) , _file (f)
, function (fn) , _function (fn)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Hook::Hook (const Hook& other) Hook::Hook (const Hook& other)
{ {
event = other.event; _event = other._event;
file = other.file; _file = other._file;
function = other.function; _function = other._function;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -66,9 +66,9 @@ Hook& Hook::operator= (const Hook& other)
{ {
if (this != &other) if (this != &other)
{ {
event = other.event; _event = other._event;
file = other.file; _file = other._file;
function = other.function; _function = other._function;
} }
return *this; return *this;
@@ -78,18 +78,18 @@ Hook& Hook::operator= (const Hook& other)
Hooks::Hooks () Hooks::Hooks ()
{ {
// New 2.x hooks. // New 2.x hooks.
validTaskEvents.push_back ("on-task-add"); // Unimplemented _validTaskEvents.push_back ("on-task-add"); // Unimplemented
validTaskEvents.push_back ("on-task-modify"); // Unimplemented _validTaskEvents.push_back ("on-task-modify"); // Unimplemented
validTaskEvents.push_back ("on-task-complete"); // Unimplemented _validTaskEvents.push_back ("on-task-complete"); // Unimplemented
validTaskEvents.push_back ("on-task-delete"); // Unimplemented _validTaskEvents.push_back ("on-task-delete"); // Unimplemented
validProgramEvents.push_back ("on-launch"); _validProgramEvents.push_back ("on-launch");
validProgramEvents.push_back ("on-exit"); _validProgramEvents.push_back ("on-exit");
validProgramEvents.push_back ("on-file-read"); // Unimplemented _validProgramEvents.push_back ("on-file-read"); // Unimplemented
validProgramEvents.push_back ("on-file-write"); // Unimplemented _validProgramEvents.push_back ("on-file-write"); // Unimplemented
validProgramEvents.push_back ("on-synch"); // Unimplemented _validProgramEvents.push_back ("on-synch"); // Unimplemented
validProgramEvents.push_back ("on-merge"); // Unimplemented _validProgramEvents.push_back ("on-merge"); // Unimplemented
validProgramEvents.push_back ("on-gc"); // Unimplemented _validProgramEvents.push_back ("on-gc"); // Unimplemented
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -104,7 +104,7 @@ Hooks::~Hooks ()
void Hooks::initialize () void Hooks::initialize ()
{ {
#ifdef HAVE_LIBLUA #ifdef HAVE_LIBLUA
api.initialize (); _api.initialize ();
#endif #endif
// Allow a master switch to turn the whole thing off. // Allow a master switch to turn the whole thing off.
@@ -142,7 +142,7 @@ void Hooks::initialize ()
{ {
context.debug (std::string ("Event '") + name + "' hooked by " + file + ", function " + function); context.debug (std::string ("Event '") + name + "' hooked by " + file + ", function " + function);
Hook h (name, Path::expand (file), function); Hook h (name, Path::expand (file), function);
all.push_back (h); _all.push_back (h);
(void) n.skip (','); (void) n.skip (',');
} }
@@ -162,16 +162,16 @@ bool Hooks::trigger (const std::string& event)
{ {
#ifdef HAVE_LIBLUA #ifdef HAVE_LIBLUA
std::vector <Hook>::iterator it; std::vector <Hook>::iterator it;
for (it = all.begin (); it != all.end (); ++it) for (it = _all.begin (); it != _all.end (); ++it)
{ {
if (it->event == event) if (it->_event == event)
{ {
Timer timer (std::string ("Hooks::trigger ") + event); Timer timer (std::string ("Hooks::trigger ") + event);
if (validProgramEvent (event)) if (validProgramEvent (event))
{ {
context.debug (std::string ("Event ") + event + " triggered"); context.debug (std::string ("Event ") + event + " triggered");
if (! api.callProgramHook (it->file, it->function)) if (! _api.callProgramHook (it->_file, it->_function))
return false; return false;
} }
else else
@@ -189,16 +189,16 @@ bool Hooks::trigger (const std::string& event, Task& task)
{ {
#ifdef HAVE_LIBLUA #ifdef HAVE_LIBLUA
std::vector <Hook>::iterator it; std::vector <Hook>::iterator it;
for (it = all.begin (); it != all.end (); ++it) for (it = _all.begin (); it != _all.end (); ++it)
{ {
if (it->event == event) if (it->_event == event)
{ {
Timer timer (std::string ("Hooks::trigger ") + event); Timer timer (std::string ("Hooks::trigger ") + event);
if (validTaskEvent (event)) if (validTaskEvent (event))
{ {
context.debug (std::string ("Event ") + event + " triggered"); context.debug (std::string ("Event ") + event + " triggered");
if (! api.callTaskHook (it->file, it->function, task)) if (! _api.callTaskHook (it->_file, it->_function, task))
return false; return false;
} }
else else
@@ -213,7 +213,7 @@ bool Hooks::trigger (const std::string& event, Task& task)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Hooks::validProgramEvent (const std::string& event) bool Hooks::validProgramEvent (const std::string& event)
{ {
if (std::find (validProgramEvents.begin (), validProgramEvents.end (), event) != validProgramEvents.end ()) if (std::find (_validProgramEvents.begin (), _validProgramEvents.end (), event) != _validProgramEvents.end ())
return true; return true;
return false; return false;
@@ -222,7 +222,7 @@ bool Hooks::validProgramEvent (const std::string& event)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Hooks::validTaskEvent (const std::string& event) bool Hooks::validTaskEvent (const std::string& event)
{ {
if (std::find (validTaskEvents.begin (), validTaskEvents.end (), event) != validTaskEvents.end ()) if (std::find (_validTaskEvents.begin (), _validTaskEvents.end (), event) != _validTaskEvents.end ())
return true; return true;
return false; return false;

View File

@@ -43,9 +43,9 @@ public:
Hook& operator= (const Hook&); Hook& operator= (const Hook&);
public: public:
std::string event; std::string _event;
std::string file; std::string _file;
std::string function; std::string _function;
}; };
// Hooks class for managing the loading and calling of hook functions. // Hooks class for managing the loading and calling of hook functions.
@@ -68,12 +68,12 @@ private:
private: private:
#ifdef HAVE_LIBLUA #ifdef HAVE_LIBLUA
API api; API _api;
#endif #endif
std::vector <Hook> all; // All current hooks. std::vector <Hook> _all; // All current hooks.
std::vector <std::string> validProgramEvents; std::vector <std::string> _validProgramEvents;
std::vector <std::string> validTaskEvents; std::vector <std::string> _validTaskEvents;
}; };
#endif #endif

View File

@@ -29,26 +29,26 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Location::Location () Location::Location ()
: path ("") : _path ("")
, pending (NULL) , _pending (NULL)
, completed (NULL) , _completed (NULL)
, undo (NULL) , _undo (NULL)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Location::Location (const std::string& p) Location::Location (const std::string& p)
: path (p) : _path (p)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Location::Location (const Location& other) Location::Location (const Location& other)
{ {
path = other.path; _path = other._path;
pending = other.pending; _pending = other._pending;
completed = other.completed; _completed = other._completed;
undo = other.undo; _undo = other._undo;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -56,10 +56,10 @@ Location& Location::operator= (const Location& other)
{ {
if (this != &other) if (this != &other)
{ {
path = other.path; _path = other._path;
pending = other.pending; _pending = other._pending;
completed = other.completed; _completed = other._completed;
undo = other.undo; _undo = other._undo;
} }
return *this; return *this;

View File

@@ -41,10 +41,10 @@ public:
~Location (); // Destructor ~Location (); // Destructor
public: public:
std::string path; std::string _path;
FILE* pending; FILE* _pending;
FILE* completed; FILE* _completed;
FILE* undo; FILE* _undo;
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@@ -89,10 +89,10 @@ public:
std::string dump (); std::string dump ();
private: private:
std::string mInput; std::string _input;
std::string::size_type mLength; std::string::size_type _length;
std::string::size_type mCursor; std::string::size_type _cursor;
std::string::size_type mSaved; std::string::size_type _saved;
}; };
#endif #endif

View File

@@ -45,13 +45,13 @@ Path::Path ()
Path::Path (const Path& other) Path::Path (const Path& other)
{ {
if (this != &other) if (this != &other)
data = other.data; _data = other._data;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Path::Path (const std::string& in) Path::Path (const std::string& in)
{ {
data = expand (in); _data = expand (in);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -63,7 +63,7 @@ Path::~Path ()
Path& Path::operator= (const Path& other) Path& Path::operator= (const Path& other)
{ {
if (this != &other) if (this != &other)
this->data = other.data; this->_data = other._data;
return *this; return *this;
} }
@@ -71,36 +71,36 @@ Path& Path::operator= (const Path& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Path::operator== (const Path& other) bool Path::operator== (const Path& other)
{ {
return data == other.data; return _data == other._data;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Path::operator std::string () const Path::operator std::string () const
{ {
return data; return _data;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Path::name () const std::string Path::name () const
{ {
if (data.length ()) if (_data.length ())
{ {
std::string::size_type slash = data.rfind ('/'); std::string::size_type 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);
} }
return data; return _data;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Path::parent () const std::string Path::parent () const
{ {
if (data.length ()) if (_data.length ())
{ {
std::string::size_type slash = data.rfind ('/'); std::string::size_type slash = _data.rfind ('/');
if (slash != std::string::npos) if (slash != std::string::npos)
return data.substr (0, slash); return _data.substr (0, slash);
} }
return ""; return "";
@@ -109,11 +109,11 @@ std::string Path::parent () const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Path::extension () const std::string Path::extension () const
{ {
if (data.length ()) if (_data.length ())
{ {
std::string::size_type dot = data.rfind ('.'); std::string::size_type 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);
} }
return ""; return "";
@@ -122,14 +122,14 @@ std::string Path::extension () const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Path::exists () const bool Path::exists () const
{ {
return access (data.c_str (), F_OK) ? false : true; return access (_data.c_str (), F_OK) ? false : true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Path::is_directory () const bool Path::is_directory () const
{ {
struct stat s = {0}; struct stat s = {0};
if (! stat (data.c_str (), &s) && if (! stat (_data.c_str (), &s) &&
s.st_mode & S_IFDIR) s.st_mode & S_IFDIR)
return true; return true;
@@ -139,7 +139,7 @@ bool Path::is_directory () const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Path::is_absolute () const bool Path::is_absolute () const
{ {
if (data.length () && data.substr (0, 1) == "/") if (_data.length () && _data.substr (0, 1) == "/")
return true; return true;
return false; return false;
@@ -148,19 +148,19 @@ bool Path::is_absolute () const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Path::readable () const bool Path::readable () const
{ {
return access (data.c_str (), R_OK) ? false : true; return access (_data.c_str (), R_OK) ? false : true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Path::writable () const bool Path::writable () const
{ {
return access (data.c_str (), W_OK) ? false : true; return access (_data.c_str (), W_OK) ? false : true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Path::executable () const bool Path::executable () const
{ {
return access (data.c_str (), X_OK) ? false : true; return access (_data.c_str (), X_OK) ? false : true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@@ -58,7 +58,7 @@ public:
static std::vector<std::string> glob (const std::string&); static std::vector<std::string> glob (const std::string&);
public: public:
std::string data; std::string _data;
}; };
#endif #endif

View File

@@ -38,25 +38,25 @@ extern Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Permission::Permission () Permission::Permission ()
: needConfirmation (false) : _need_confirmation (false)
, allConfirmed (false) , _all_confirmed (false)
, quit (false) , _quit (false)
{ {
// Turning confirmations off is the same as entering "all". // Turning confirmations off is the same as entering "all".
if (context.config.getBoolean ("confirmation") == false) if (context.config.getBoolean ("confirmation") == false)
allConfirmed = true; _all_confirmed = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Permission::confirmed (const Task& task, const std::string& question) bool Permission::confirmed (const Task& task, const std::string& question)
{ {
if (quit) if (_quit)
return false; return false;
if (!needConfirmation) if (!_need_confirmation)
return true; return true;
if (allConfirmed) if (_all_confirmed)
return true; return true;
std::cout << "\n" std::cout << "\n"
@@ -75,13 +75,13 @@ bool Permission::confirmed (const Task& task, const std::string& question)
std::cout << "\n"; // #499 std::cout << "\n"; // #499
if (answer == 2) if (answer == 2)
allConfirmed = true; _all_confirmed = true;
if (answer == 1 || answer == 2) if (answer == 1 || answer == 2)
return true; return true;
if (answer == 3) if (answer == 3)
quit = true; _quit = true;
return false; return false;
} }

View File

@@ -38,14 +38,14 @@ public:
Permission (const Permission&); Permission (const Permission&);
Permission& operator= (const Permission&); Permission& operator= (const Permission&);
void bigChange () { needConfirmation = true; } void bigChange () { _need_confirmation = true; }
void bigSequence () { needConfirmation = true; } void bigSequence () { _need_confirmation = true; }
bool confirmed (const Task&, const std::string&); bool confirmed (const Task&, const std::string&);
private: private:
bool needConfirmation; bool _need_confirmation;
bool allConfirmed; bool _all_confirmed;
bool quit; bool _quit;
}; };
#endif #endif

View File

@@ -144,34 +144,34 @@ void readTaskmods (std::vector <std::string> &input,
// [TDB::unlock] // [TDB::unlock]
// //
TDB::TDB () TDB::TDB ()
: mLock (true) : _lock (true)
, mAllOpenAndLocked (false) , _all_opened_and_locked (false)
, mId (1) , _id (1)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TDB::~TDB () TDB::~TDB ()
{ {
if (mAllOpenAndLocked) if (_all_opened_and_locked)
unlock (); unlock ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TDB::clear () void TDB::clear ()
{ {
mLocations.clear (); _locations.clear ();
mLock = true; _lock = true;
if (mAllOpenAndLocked) if (_all_opened_and_locked)
unlock (); unlock ();
mAllOpenAndLocked = false; _all_opened_and_locked = false;
mId = 1; _id = 1;
mPending.clear (); _pending.clear ();
mNew.clear (); _new.clear ();
mCompleted.clear (); _completed.clear ();
mModified.clear (); _modified.clear ();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -183,53 +183,53 @@ void TDB::location (const std::string& path)
path + path +
"' does not exist, or is not readable and writable."; "' does not exist, or is not readable and writable.";
mLocations.push_back (Location (d)); _locations.push_back (Location (d));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TDB::lock (bool lockFile /* = true */) void TDB::lock (bool lockFile /* = true */)
{ {
mLock = lockFile; _lock = lockFile;
mPending.clear (); _pending.clear ();
mNew.clear (); _new.clear ();
mCompleted.clear (); _completed.clear ();
mModified.clear (); _modified.clear ();
foreach (location, mLocations) foreach (location, _locations)
{ {
location->pending = openAndLock (location->path + "/pending.data"); location->_pending = openAndLock (location->_path + "/pending.data");
location->completed = openAndLock (location->path + "/completed.data"); location->_completed = openAndLock (location->_path + "/completed.data");
location->undo = openAndLock (location->path + "/undo.data"); location->_undo = openAndLock (location->_path + "/undo.data");
} }
mAllOpenAndLocked = true; _all_opened_and_locked = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TDB::unlock () void TDB::unlock ()
{ {
// Do not clear out these items, as they may be used in a read-only fashion. // Do not clear out these items, as they may be used in a read-only fashion.
// mPending.clear (); // _pending.clear ();
// mNew.clear (); // _new.clear ();
// mModified.clear (); // _modified.clear ();
foreach (location, mLocations) foreach (location, _locations)
{ {
fflush (location->pending); fflush (location->_pending);
fclose (location->pending); fclose (location->_pending);
location->pending = NULL; location->_pending = NULL;
fflush (location->completed); fflush (location->_completed);
fclose (location->completed); fclose (location->_completed);
location->completed = NULL; location->_completed = NULL;
fflush (location->undo); fflush (location->_undo);
fclose (location->undo); fclose (location->_undo);
location->completed = NULL; location->_completed = NULL;
} }
mAllOpenAndLocked = false; _all_opened_and_locked = false;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -280,32 +280,32 @@ int TDB::loadPending (std::vector <Task>& tasks)
try try
{ {
// Only load if not already loaded. // Only load if not already loaded.
if (mPending.size () == 0) if (_pending.size () == 0)
{ {
mId = 1; _id = 1;
char line[T_LINE_MAX]; char line[T_LINE_MAX];
foreach (location, mLocations) foreach (location, _locations)
{ {
line_number = 1; line_number = 1;
file = location->path + "/pending.data"; file = location->_path + "/pending.data";
fseek (location->pending, 0, SEEK_SET); fseek (location->_pending, 0, SEEK_SET);
while (fgets (line, T_LINE_MAX, location->pending)) while (fgets (line, T_LINE_MAX, location->_pending))
{ {
int length = strlen (line); int length = strlen (line);
if (length > 3) // []\n if (length > 3) // []\n
{ {
// TODO Add hidden attribute indicating source? // TODO Add hidden attribute indicating source?
Task task (line); Task task (line);
task.id = mId++; task.id = _id++;
mPending.push_back (task); _pending.push_back (task);
// Maintain mapping for ease of link/dependency resolution. // Maintain mapping for ease of link/dependency resolution.
// Note that this mapping is not restricted by the filter, and is // Note that this mapping is not restricted by the filter, and is
// therefore a complete set. // therefore a complete set.
mI2U[task.id] = task.get ("uuid"); _I2U[task.id] = task.get ("uuid");
mU2I[task.get ("uuid")] = task.id; _U2I[task.get ("uuid")] = task.id;
} }
++line_number; ++line_number;
@@ -314,13 +314,13 @@ int TDB::loadPending (std::vector <Task>& tasks)
} }
// Now filter and return. // Now filter and return.
foreach (task, mPending) foreach (task, _pending)
tasks.push_back (*task); tasks.push_back (*task);
// Hand back any accumulated additions, if TDB::loadPending is being called // Hand back any accumulated additions, if TDB::loadPending is being called
// repeatedly. // repeatedly.
int fakeId = mId; int fakeId = _id;
foreach (task, mNew) foreach (task, _new)
{ {
task->id = fakeId++; task->id = fakeId++;
tasks.push_back (*task); tasks.push_back (*task);
@@ -348,16 +348,16 @@ int TDB::loadCompleted (std::vector <Task>& tasks)
try try
{ {
if (mCompleted.size () == 0) if (_completed.size () == 0)
{ {
char line[T_LINE_MAX]; char line[T_LINE_MAX];
foreach (location, mLocations) foreach (location, _locations)
{ {
line_number = 1; line_number = 1;
file = location->path + "/completed.data"; file = location->_path + "/completed.data";
fseek (location->completed, 0, SEEK_SET); fseek (location->_completed, 0, SEEK_SET);
while (fgets (line, T_LINE_MAX, location->completed)) while (fgets (line, T_LINE_MAX, location->_completed))
{ {
int length = strlen (line); int length = strlen (line);
if (length > 3) // []\n if (length > 3) // []\n
@@ -367,7 +367,7 @@ int TDB::loadCompleted (std::vector <Task>& tasks)
Task task (line); Task task (line);
task.id = 0; // Need a value, just not a valid value. task.id = 0; // Need a value, just not a valid value.
mCompleted.push_back (task); _completed.push_back (task);
} }
++line_number; ++line_number;
@@ -376,7 +376,7 @@ int TDB::loadCompleted (std::vector <Task>& tasks)
} }
// Now filter and return. // Now filter and return.
foreach (task, mCompleted) foreach (task, _completed)
tasks.push_back (*task); tasks.push_back (*task);
} }
@@ -393,29 +393,29 @@ int TDB::loadCompleted (std::vector <Task>& tasks)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::vector <Task>& TDB::getAllPending () const std::vector <Task>& TDB::getAllPending ()
{ {
return mPending; return _pending;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::vector <Task>& TDB::getAllNew () const std::vector <Task>& TDB::getAllNew ()
{ {
return mNew; return _new;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::vector <Task>& TDB::getAllCompleted () const std::vector <Task>& TDB::getAllCompleted ()
{ {
return mCompleted; return _completed;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::vector <Task>& TDB::getAllModified () const std::vector <Task>& TDB::getAllModified ()
{ {
return mModified; return _modified;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Note: mLocations[0] is where all tasks are written. // Note: _locations[0] is where all tasks are written.
void TDB::add (const Task& task) void TDB::add (const Task& task)
{ {
std::string unique; std::string unique;
@@ -429,21 +429,21 @@ void TDB::add (const Task& task)
// If the tasks are loaded, then verify that this uuid is not already in // If the tasks are loaded, then verify that this uuid is not already in
// the file. // the file.
if (uuidAlreadyUsed (unique, mNew) || if (uuidAlreadyUsed (unique, _new) ||
uuidAlreadyUsed (unique, mModified) || uuidAlreadyUsed (unique, _modified) ||
uuidAlreadyUsed (unique, mPending) || uuidAlreadyUsed (unique, _pending) ||
uuidAlreadyUsed (unique, mCompleted)) uuidAlreadyUsed (unique, _completed))
throw std::string ("Cannot add task because the uuid '") + unique + "' is not unique."; throw std::string ("Cannot add task because the uuid '") + unique + "' is not unique.";
mNew.push_back (t); _new.push_back (t);
mI2U[task.id] = unique; _I2U[task.id] = unique;
mU2I[task.get ("uuid")] = t.id; _U2I[task.get ("uuid")] = t.id;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TDB::update (const Task& task) void TDB::update (const Task& task)
{ {
mModified.push_back (task); _modified.push_back (task);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -453,35 +453,35 @@ int TDB::commit ()
{ {
context.timer_gc.start (); context.timer_gc.start ();
int quantity = mNew.size () + mModified.size (); int quantity = _new.size () + _modified.size ();
// This is an optimization. If there are only new tasks, and none were // This is an optimization. If there are only new tasks, and none were
// modified, simply seek to the end of pending and write. // modified, simply seek to the end of pending and write.
if (mNew.size () && ! mModified.size ()) if (_new.size () && ! _modified.size ())
{ {
fseek (mLocations[0].pending, 0, SEEK_END); fseek (_locations[0]._pending, 0, SEEK_END);
foreach (task, mNew) foreach (task, _new)
{ {
mPending.push_back (*task); _pending.push_back (*task);
fputs (task->composeF4 ().c_str (), mLocations[0].pending); fputs (task->composeF4 ().c_str (), _locations[0]._pending);
} }
fseek (mLocations[0].undo, 0, SEEK_END); fseek (_locations[0]._undo, 0, SEEK_END);
foreach (task, mNew) foreach (task, _new)
writeUndo (*task, mLocations[0].undo); writeUndo (*task, _locations[0]._undo);
mNew.clear (); _new.clear ();
return quantity; return quantity;
} }
// The alternative is to potentially rewrite both files. // The alternative is to potentially rewrite both files.
else if (mNew.size () || mModified.size ()) else if (_new.size () || _modified.size ())
{ {
// allPending is a copy of mPending, with all modifications included, and // allPending is a copy of _pending, with all modifications included, and
// new tasks appended. // new tasks appended.
std::vector <Task> allPending; std::vector <Task> allPending;
allPending = mPending; allPending = _pending;
foreach (mtask, mModified) foreach (mtask, _modified)
{ {
foreach (task, allPending) foreach (task, allPending)
{ {
@@ -496,29 +496,29 @@ int TDB::commit ()
; ;
} }
foreach (task, mNew) foreach (task, _new)
allPending.push_back (*task); allPending.push_back (*task);
// Write out all pending. // Write out all pending.
if (fseek (mLocations[0].pending, 0, SEEK_SET) == 0) if (fseek (_locations[0]._pending, 0, SEEK_SET) == 0)
{ {
if (ftruncate (fileno (mLocations[0].pending), 0)) if (ftruncate (fileno (_locations[0]._pending), 0))
throw std::string ("Failed to truncate pending.data file "); throw std::string ("Failed to truncate pending.data file ");
foreach (task, allPending) foreach (task, allPending)
fputs (task->composeF4 ().c_str (), mLocations[0].pending); fputs (task->composeF4 ().c_str (), _locations[0]._pending);
} }
// Update the undo log. // Update the undo log.
if (fseek (mLocations[0].undo, 0, SEEK_END) == 0) if (fseek (_locations[0]._undo, 0, SEEK_END) == 0)
{ {
foreach (mtask, mModified) foreach (mtask, _modified)
{ {
foreach (task, mPending) foreach (task, _pending)
{ {
if (task->id == mtask->id) if (task->id == mtask->id)
{ {
writeUndo (*task, *mtask, mLocations[0].undo); writeUndo (*task, *mtask, _locations[0]._undo);
goto next_mod2; goto next_mod2;
} }
} }
@@ -527,14 +527,14 @@ int TDB::commit ()
; ;
} }
foreach (task, mNew) foreach (task, _new)
writeUndo (*task, mLocations[0].undo); writeUndo (*task, _locations[0]._undo);
} }
mPending = allPending; _pending = allPending;
mModified.clear (); _modified.clear ();
mNew.clear (); _new.clear ();
} }
context.timer_gc.stop (); context.timer_gc.stop ();
@@ -561,10 +561,10 @@ int TDB::gc ()
int count_completed_changes = 0; int count_completed_changes = 0;
Date now; Date now;
if (mNew.size ()) if (_new.size ())
throw std::string ("Unexpected new tasks found during gc."); throw std::string ("Unexpected new tasks found during gc.");
if (mModified.size ()) if (_modified.size ())
throw std::string ("Unexpected modified tasks found during gc."); throw std::string ("Unexpected modified tasks found during gc.");
lock (); lock ();
@@ -575,7 +575,7 @@ int TDB::gc ()
// Search for dangling dependencies. These are dependencies whose uuid cannot // Search for dangling dependencies. These are dependencies whose uuid cannot
// be converted to an id by TDB. // be converted to an id by TDB.
std::vector <std::string> deps; std::vector <std::string> deps;
foreach (task, mPending) foreach (task, _pending)
{ {
if (task->has ("depends")) if (task->has ("depends"))
{ {
@@ -600,7 +600,7 @@ int TDB::gc ()
// completed list. Isn't garbage collection easy? // completed list. Isn't garbage collection easy?
std::vector <Task> still_pending; std::vector <Task> still_pending;
std::vector <Task> newly_completed; std::vector <Task> newly_completed;
foreach (task, mPending) foreach (task, _pending)
{ {
Task::status s = task->getStatus (); Task::status s = task->getStatus ();
if (s == Task::completed || if (s == Task::completed ||
@@ -633,16 +633,16 @@ int TDB::gc ()
// No commit - all updates performed manually. // No commit - all updates performed manually.
if (count_pending_changes > 0) if (count_pending_changes > 0)
{ {
if (fseek (mLocations[0].pending, 0, SEEK_SET) == 0) if (fseek (_locations[0]._pending, 0, SEEK_SET) == 0)
{ {
if (ftruncate (fileno (mLocations[0].pending), 0)) if (ftruncate (fileno (_locations[0]._pending), 0))
throw std::string ("Failed to truncate pending.data file "); throw std::string ("Failed to truncate pending.data file ");
foreach (task, still_pending) foreach (task, still_pending)
fputs (task->composeF4 ().c_str (), mLocations[0].pending); fputs (task->composeF4 ().c_str (), _locations[0]._pending);
// Update cached copy. // Update cached copy.
mPending = still_pending; _pending = still_pending;
} }
} }
@@ -650,9 +650,9 @@ int TDB::gc ()
// whole list. // whole list.
if (count_completed_changes > 0) if (count_completed_changes > 0)
{ {
fseek (mLocations[0].completed, 0, SEEK_END); fseek (_locations[0]._completed, 0, SEEK_END);
foreach (task, newly_completed) foreach (task, newly_completed)
fputs (task->composeF4 ().c_str (), mLocations[0].completed); fputs (task->composeF4 ().c_str (), _locations[0]._completed);
} }
// Close files. // Close files.
@@ -669,7 +669,7 @@ int TDB::gc ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int TDB::nextId () int TDB::nextId ()
{ {
return mId++; return _id++;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -677,9 +677,9 @@ void TDB::undo ()
{ {
Directory location (context.config.get ("data.location")); Directory location (context.config.get ("data.location"));
std::string undoFile = location.data + "/undo.data"; std::string undoFile = location._data + "/undo.data";
std::string pendingFile = location.data + "/pending.data"; std::string pendingFile = location._data + "/pending.data";
std::string completedFile = location.data + "/completed.data"; std::string completedFile = location._data + "/completed.data";
// load undo.data // load undo.data
std::vector <std::string> u; std::vector <std::string> u;
@@ -1043,7 +1043,7 @@ void TDB::merge (const std::string& mergeFile)
// load undo file (left/local branch) // load undo file (left/local branch)
Directory location (context.config.get ("data.location")); Directory location (context.config.get ("data.location"));
std::string undoFile = location.data + "/undo.data"; std::string undoFile = location._data + "/undo.data";
std::vector <std::string> l; std::vector <std::string> l;
if (! File::read (undoFile, l)) if (! File::read (undoFile, l))
@@ -1364,10 +1364,10 @@ void TDB::merge (const std::string& mergeFile)
if (!mods.empty ()) if (!mods.empty ())
{ {
std::string pendingFile = location.data + "/pending.data"; std::string pendingFile = location._data + "/pending.data";
std::vector <std::string> pending; std::vector <std::string> pending;
std::string completedFile = location.data + "/completed.data"; std::string completedFile = location._data + "/completed.data";
std::vector <std::string> completed; std::vector <std::string> completed;
if (! File::read (pendingFile, pending)) if (! File::read (pendingFile, pending))
@@ -1560,7 +1560,7 @@ void TDB::merge (const std::string& mergeFile)
std::string TDB::uuid (int id) const std::string TDB::uuid (int id) const
{ {
std::map <int, std::string>::const_iterator i; std::map <int, std::string>::const_iterator i;
if ((i = mI2U.find (id)) != mI2U.end ()) if ((i = _I2U.find (id)) != _I2U.end ())
return i->second; return i->second;
return ""; return "";
@@ -1570,7 +1570,7 @@ std::string TDB::uuid (int id) const
int TDB::id (const std::string& uuid) const int TDB::id (const std::string& uuid) const
{ {
std::map <std::string, int>::const_iterator i; std::map <std::string, int>::const_iterator i;
if ((i = mU2I.find (uuid)) != mU2I.end ()) if ((i = _U2I.find (uuid)) != _U2I.end ())
return i->second; return i->second;
return 0; return 0;
@@ -1595,7 +1595,7 @@ FILE* TDB::openAndLock (const std::string& file)
throw std::string ("Could not open '") + file + "'."; throw std::string ("Could not open '") + file + "'.";
// Lock if desired. Try three times before failing. // Lock if desired. Try three times before failing.
if (mLock) if (_lock)
{ {
int retry = 0; int retry = 0;
while (flock (fileno (in), LOCK_NB | LOCK_EX) && ++retry <= 3) while (flock (fileno (in), LOCK_NB | LOCK_EX) && ++retry <= 3)

View File

@@ -80,18 +80,18 @@ private:
bool uuidAlreadyUsed (const std::string&, const std::vector <Task>&); bool uuidAlreadyUsed (const std::string&, const std::vector <Task>&);
private: private:
std::vector <Location> mLocations; std::vector <Location> _locations;
bool mLock; bool _lock;
bool mAllOpenAndLocked; bool _all_opened_and_locked;
int mId; int _id;
std::vector <Task> mPending; // Contents of pending.data std::vector <Task> _pending; // Contents of pending.data
std::vector <Task> mCompleted; // Contents of pending.data std::vector <Task> _completed; // Contents of pending.data
std::vector <Task> mNew; // Uncommitted new tasks std::vector <Task> _new; // Uncommitted new tasks
std::vector <Task> mModified; // Uncommitted modified tasks std::vector <Task> _modified; // Uncommitted modified tasks
std::map <int, std::string> mI2U; // ID -> UUID map std::map <int, std::string> _I2U; // ID -> UUID map
std::map <std::string, int> mU2I; // UUID -> ID map std::map <std::string, int> _U2I; // UUID -> ID map
}; };
#endif #endif

View File

@@ -62,7 +62,7 @@ void TF2::target (const std::string& f)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::vector <Task>& TF2::get_tasks () const std::vector <Task>& TF2::get_tasks ()
{ {
// std::cout << "# TF2::get_tasks " << _file.data << "\n"; // std::cout << "# TF2::get_tasks " << _file._data << "\n";
if (! _loaded_tasks) if (! _loaded_tasks)
load_tasks (); load_tasks ();
@@ -73,7 +73,7 @@ const std::vector <Task>& TF2::get_tasks ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::vector <std::string>& TF2::get_lines () const std::vector <std::string>& TF2::get_lines ()
{ {
// std::cout << "# TF2::get_lines " << _file.data << "\n"; // std::cout << "# TF2::get_lines " << _file._data << "\n";
if (! _loaded_lines) if (! _loaded_lines)
load_lines (); load_lines ();
@@ -84,7 +84,7 @@ const std::vector <std::string>& TF2::get_lines ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::string& TF2::get_contents () const std::string& TF2::get_contents ()
{ {
// std::cout << "# TF2::get_contents " << _file.data << "\n"; // std::cout << "# TF2::get_contents " << _file._data << "\n";
if (! _loaded_contents) if (! _loaded_contents)
load_contents (); load_contents ();
@@ -95,7 +95,7 @@ const std::string& TF2::get_contents ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TF2::add_task (const Task& task) void TF2::add_task (const Task& task)
{ {
// std::cout << "# TF2::add_task " << _file.data << "\n"; // std::cout << "# TF2::add_task " << _file._data << "\n";
_tasks.push_back (task); // For subsequent queries _tasks.push_back (task); // For subsequent queries
_added_tasks.push_back (task); // For commit/synch _added_tasks.push_back (task); // For commit/synch
@@ -112,7 +112,7 @@ void TF2::add_task (const Task& task)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TF2::modify_task (const Task& task) void TF2::modify_task (const Task& task)
{ {
// std::cout << "# TF2::modify_task " << _file.data << "\n"; // std::cout << "# TF2::modify_task " << _file._data << "\n";
// Modify in-place. // Modify in-place.
std::vector <Task>::iterator i; std::vector <Task>::iterator i;
@@ -132,7 +132,7 @@ void TF2::modify_task (const Task& task)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TF2::add_line (const std::string& line) void TF2::add_line (const std::string& line)
{ {
// std::cout << "# TF2::add_line " << _file.data << "\n"; // std::cout << "# TF2::add_line " << _file._data << "\n";
_added_lines.push_back (line); _added_lines.push_back (line);
_dirty = true; _dirty = true;
@@ -142,7 +142,7 @@ void TF2::add_line (const std::string& line)
// This is so that synch.key can just overwrite and not grow. // This is so that synch.key can just overwrite and not grow.
void TF2::clear_lines () void TF2::clear_lines ()
{ {
// std::cout << "# TF2::clear_lines " << _file.data << "\n"; // std::cout << "# TF2::clear_lines " << _file._data << "\n";
_lines.clear (); _lines.clear ();
_dirty = true; _dirty = true;
} }
@@ -151,7 +151,7 @@ void TF2::clear_lines ()
// Top-down recomposition. // Top-down recomposition.
void TF2::commit () void TF2::commit ()
{ {
// std::cout << "# TF2::commit " << _file.data << "\n"; // std::cout << "# TF2::commit " << _file._data << "\n";
// The _dirty flag indicates that the file needs to be written. // The _dirty flag indicates that the file needs to be written.
if (_dirty) if (_dirty)
@@ -227,7 +227,7 @@ void TF2::commit ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TF2::load_tasks () void TF2::load_tasks ()
{ {
// std::cout << "# TF2::load_tasks " << _file.data << "\n"; // std::cout << "# TF2::load_tasks " << _file._data << "\n";
context.timer_load.start (); context.timer_load.start ();
if (! _loaded_lines) if (! _loaded_lines)
@@ -266,7 +266,7 @@ void TF2::load_tasks ()
catch (std::string& e) catch (std::string& e)
{ {
throw e + format (" in {1} at line {2}", _file.data, line_number); throw e + format (" in {1} at line {2}", _file._data, line_number);
} }
context.timer_load.stop (); context.timer_load.stop ();
@@ -275,7 +275,7 @@ void TF2::load_tasks ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TF2::load_lines () void TF2::load_lines ()
{ {
// std::cout << "# TF2::load_lines " << _file.data << "\n"; // std::cout << "# TF2::load_lines " << _file._data << "\n";
if (! _loaded_contents) if (! _loaded_contents)
load_contents (); load_contents ();
@@ -287,7 +287,7 @@ void TF2::load_lines ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TF2::load_contents () void TF2::load_contents ()
{ {
// std::cout << "# TF2::load_contents " << _file.data << "\n"; // std::cout << "# TF2::load_contents " << _file._data << "\n";
_contents = ""; _contents = "";
@@ -345,9 +345,9 @@ const std::string TF2::dump ()
// File label. // File label.
std::string label; std::string label;
std::string::size_type slash = _file.data.rfind ('/'); std::string::size_type 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);
// File mode. // File mode.
std::string mode = std::string (_file.readable () ? "r" : "-") + std::string mode = std::string (_file.readable () ? "r" : "-") +

View File

@@ -36,19 +36,19 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Taskmod::Taskmod () Taskmod::Taskmod ()
{ {
timestamp = 0; _timestamp = 0;
bAfterSet = false; _bAfterSet = false;
bBeforeSet = false; _bBeforeSet = false;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Taskmod::Taskmod (const Taskmod& other) Taskmod::Taskmod (const Taskmod& other)
{ {
this->before = other.before; this->_before = other._before;
this->after = other.after; this->_after = other._after;
this->timestamp = other.timestamp; this->_timestamp = other._timestamp;
this->bAfterSet = other.bAfterSet; this->_bAfterSet = other._bAfterSet;
this->bBeforeSet = other.bBeforeSet; this->_bBeforeSet = other._bBeforeSet;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -59,21 +59,21 @@ Taskmod::~Taskmod ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Taskmod::operator< (const Taskmod &compare) bool Taskmod::operator< (const Taskmod &compare)
{ {
return (timestamp < compare.getTimestamp ()); return (_timestamp < compare.getTimestamp ());
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Taskmod::operator> (const Taskmod &compare) bool Taskmod::operator> (const Taskmod &compare)
{ {
return (timestamp > compare.getTimestamp ()); return (_timestamp > compare.getTimestamp ());
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Taskmod::operator== (const Taskmod& compare) bool Taskmod::operator== (const Taskmod& compare)
{ {
return ( (compare.after == this->after) return ( (compare._after == this->_after)
&& (compare.before == this->before) && (compare._before == this->_before)
&& (compare.timestamp == this->timestamp) ); && (compare._timestamp == this->_timestamp) );
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -87,11 +87,11 @@ Taskmod& Taskmod::operator= (const Taskmod& other)
{ {
if (this != &other) if (this != &other)
{ {
this->before = other.before; this->_before = other._before;
this->after = other.after; this->_after = other._after;
this->timestamp = other.timestamp; this->_timestamp = other._timestamp;
this->bAfterSet = other.bAfterSet; this->_bAfterSet = other._bAfterSet;
this->bBeforeSet = other.bBeforeSet; this->_bBeforeSet = other._bBeforeSet;
} }
return *this; return *this;
@@ -100,58 +100,58 @@ Taskmod& Taskmod::operator= (const Taskmod& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Taskmod::reset (long timestamp) void Taskmod::reset (long timestamp)
{ {
this->bAfterSet = false; this->_bAfterSet = false;
this->bBeforeSet = false; this->_bBeforeSet = false;
this->timestamp = timestamp; this->_timestamp = timestamp;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Taskmod::isNew () bool Taskmod::isNew ()
{ {
return !bBeforeSet; return !_bBeforeSet;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Taskmod::issetAfter () bool Taskmod::issetAfter ()
{ {
return bAfterSet; return _bAfterSet;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Taskmod::issetBefore () bool Taskmod::issetBefore ()
{ {
return bBeforeSet; return _bBeforeSet;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Taskmod::isValid () bool Taskmod::isValid ()
{ {
return (timestamp > 0) && (bAfterSet); return (_timestamp > 0) && (_bAfterSet);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Taskmod::getUuid () std::string Taskmod::getUuid ()
{ {
if (!bAfterSet) if (!_bAfterSet)
throw std::string (STRING_TASKMOD_BAD_INIT); throw std::string (STRING_TASKMOD_BAD_INIT);
return after.get ("uuid"); return _after.get ("uuid");
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Taskmod::toString () std::string Taskmod::toString ()
{ {
assert (bAfterSet); assert (_bAfterSet);
std::stringstream stream; std::stringstream stream;
stream << STRING_TASKMOD_TIME << timestamp << "\n"; stream << STRING_TASKMOD_TIME << _timestamp << "\n";
if (bBeforeSet) if (_bBeforeSet)
{ {
stream << STRING_TASKMOD_OLD << before.composeF4(); stream << STRING_TASKMOD_OLD << _before.composeF4();
} }
stream << STRING_TASKMOD_NEW << after.composeF4(); stream << STRING_TASKMOD_NEW << _after.composeF4();
stream << "---\n"; stream << "---\n";
return stream.str (); return stream.str ();
@@ -160,46 +160,46 @@ std::string Taskmod::toString ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Taskmod::setAfter (const Task& after) void Taskmod::setAfter (const Task& after)
{ {
this->after = after; this->_after = after;
this->bAfterSet = true; this->_bAfterSet = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Taskmod::setBefore (const Task& before) void Taskmod::setBefore (const Task& before)
{ {
this->before = before; this->_before = before;
this->bBeforeSet = true; this->_bBeforeSet = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Taskmod::setTimestamp (long timestamp) void Taskmod::setTimestamp (long timestamp)
{ {
this->timestamp = timestamp; this->_timestamp = timestamp;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Task& Taskmod::getAfter () Task& Taskmod::getAfter ()
{ {
return after; return _after;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Task& Taskmod::getBefore () Task& Taskmod::getBefore ()
{ {
return before; return _before;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
long Taskmod::getTimestamp () const long Taskmod::getTimestamp () const
{ {
return timestamp; return _timestamp;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Taskmod::getTimeStr () const std::string Taskmod::getTimeStr () const
{ {
std::stringstream sstream; std::stringstream sstream;
sstream << timestamp; sstream << _timestamp;
return sstream.str (); return sstream.str ();
} }

View File

@@ -66,11 +66,11 @@ public:
std::string getTimeStr () const; std::string getTimeStr () const;
protected: protected:
Task after; Task _after;
Task before; Task _before;
long timestamp; long _timestamp;
bool bAfterSet; bool _bAfterSet;
bool bBeforeSet; bool _bBeforeSet;
}; };
#endif #endif

View File

@@ -38,8 +38,8 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Transport::Transport (const Uri& uri) Transport::Transport (const Uri& uri)
{ {
executable = ""; _executable = "";
this->uri = uri; this->_uri = uri;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -50,17 +50,17 @@ Transport::~Transport ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Transport* Transport::getTransport(const Uri& uri) Transport* Transport::getTransport(const Uri& uri)
{ {
if (uri.protocol == "ssh") if (uri._protocol == "ssh")
{ {
return new TransportSSH(uri); return new TransportSSH(uri);
} }
else if (uri.protocol == "rsync") else if (uri._protocol == "rsync")
{ {
return new TransportRSYNC(uri); return new TransportRSYNC(uri);
} }
else if ( (uri.protocol == "http") else if ( (uri._protocol == "http")
|| (uri.protocol == "https") || (uri._protocol == "https")
|| (uri.protocol == "ftp") ) || (uri._protocol == "ftp") )
{ {
return new TransportCurl(uri); return new TransportCurl(uri);
} }
@@ -71,7 +71,7 @@ Transport* Transport::getTransport(const Uri& uri)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int Transport::execute() int Transport::execute()
{ {
return ::execute(executable, arguments); return ::execute(_executable, _arguments);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@@ -46,10 +46,10 @@ public:
static bool is_filelist(const std::string&); static bool is_filelist(const std::string&);
protected: protected:
std::string executable; std::string _executable;
std::vector<std::string> arguments; std::vector<std::string> _arguments;
Uri uri; Uri _uri;
int execute(); int execute();
}; };

View File

@@ -35,19 +35,19 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TransportCurl::TransportCurl(const Uri& uri) : Transport(uri) TransportCurl::TransportCurl(const Uri& uri) : Transport(uri)
{ {
executable = "curl"; _executable = "curl";
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TransportCurl::send(const std::string& source) void TransportCurl::send(const std::string& source)
{ {
if (uri.host == "") if (_uri._host == "")
throw std::string (STRING_TRANSPORT_CURL_URI); throw std::string (STRING_TRANSPORT_CURL_URI);
if (uri.user != "") if (_uri._user != "")
{ {
arguments.push_back("--user"); _arguments.push_back("--user");
arguments.push_back(uri.user); _arguments.push_back(_uri._user);
} }
if (is_filelist(source)) if (is_filelist(source))
@@ -58,26 +58,26 @@ void TransportCurl::send(const std::string& source)
if (pos == std::string::npos) if (pos == std::string::npos)
throw std::string (STRING_TRANSPORT_CURL_WILDCD); throw std::string (STRING_TRANSPORT_CURL_WILDCD);
if (!uri.is_directory()) if (!_uri.is_directory())
throw format (STRING_TRANSPORT_URI_NODIR, uri.path); throw format (STRING_TRANSPORT_URI_NODIR, _uri._path);
arguments.push_back ("-T"); _arguments.push_back ("-T");
arguments.push_back ("\"" + source + "\""); _arguments.push_back ("\"" + source + "\"");
} }
else else
{ {
arguments.push_back ("-T"); _arguments.push_back ("-T");
arguments.push_back (source); _arguments.push_back (source);
} }
// cmd line is: curl -T source protocol://host:port/path // cmd line is: curl -T source protocol://host:port/path
if (uri.port != "") if (_uri._port != "")
{ {
arguments.push_back (uri.protocol + "://" + uri.host + ":" + uri.port + "/" + uri.path); _arguments.push_back (_uri._protocol + "://" + _uri._host + ":" + _uri._port + "/" + _uri._path);
} }
else else
{ {
arguments.push_back (uri.protocol + "://" + uri.host + "/" + uri.path); _arguments.push_back (_uri._protocol + "://" + _uri._host + "/" + _uri._path);
} }
int result = execute(); int result = execute();
@@ -93,20 +93,20 @@ void TransportCurl::send(const std::string& source)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TransportCurl::recv(std::string target) void TransportCurl::recv(std::string target)
{ {
if (uri.host == "") if (_uri._host == "")
throw std::string (STRING_TRANSPORT_CURL_URI); throw std::string (STRING_TRANSPORT_CURL_URI);
if (uri.user != "") if (_uri._user != "")
{ {
arguments.push_back("--user"); _arguments.push_back("--user");
arguments.push_back(uri.user); _arguments.push_back(_uri._user);
} }
if (is_filelist(uri.path)) if (is_filelist(_uri._path))
{ {
std::string::size_type pos; std::string::size_type pos;
pos = uri.path.find("{"); pos = _uri._path.find("{");
if (pos == std::string::npos) if (pos == std::string::npos)
throw std::string (STRING_TRANSPORT_CURL_WILDCD); throw std::string (STRING_TRANSPORT_CURL_WILDCD);
@@ -118,7 +118,7 @@ void TransportCurl::recv(std::string target)
std::string suffix; std::string suffix;
std::string prefix = target; std::string prefix = target;
std::vector<std::string> splitted; std::vector<std::string> splitted;
toSplit = uri.path.substr (pos+1); toSplit = _uri._path.substr (pos+1);
pos = toSplit.find ("}"); pos = toSplit.find ("}");
suffix = toSplit.substr (pos+1); suffix = toSplit.substr (pos+1);
split (splitted, toSplit.substr(0, pos), ','); split (splitted, toSplit.substr(0, pos), ',');
@@ -135,16 +135,16 @@ void TransportCurl::recv(std::string target)
} }
// cmd line is: curl protocol://host:port/path/to/source/file -o path/to/target/file // cmd line is: curl protocol://host:port/path/to/source/file -o path/to/target/file
if (uri.port != "") if (_uri._port != "")
{ {
arguments.push_back (uri.protocol + "://" + uri.host + ":" + uri.port + "/" + uri.path); _arguments.push_back (_uri._protocol + "://" + _uri._host + ":" + _uri._port + "/" + _uri._path);
} }
else else
{ {
arguments.push_back (uri.protocol + "://" + uri.host + "/" + uri.path); _arguments.push_back (_uri._protocol + "://" + _uri._host + "/" + _uri._path);
} }
arguments.push_back (target); _arguments.push_back (target);
int result = execute(); int result = execute();
if (result) if (result)

View File

@@ -34,35 +34,35 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TransportRSYNC::TransportRSYNC(const Uri& uri) : Transport(uri) TransportRSYNC::TransportRSYNC(const Uri& uri) : Transport(uri)
{ {
executable = "rsync"; _executable = "rsync";
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TransportRSYNC::send(const std::string& source) void TransportRSYNC::send(const std::string& source)
{ {
if (uri.host == "") if (_uri._host == "")
throw std::string (STRING_TRANSPORT_RSYNC_URI); throw std::string (STRING_TRANSPORT_RSYNC_URI);
// Is there more than one file to transfer? // Is there more than one file to transfer?
// Then path has to end with a '/' // Then path has to end with a '/'
if (is_filelist(source) && !uri.is_directory()) if (is_filelist(source) && !_uri.is_directory())
throw format (STRING_TRANSPORT_URI_NODIR, uri.path); throw format (STRING_TRANSPORT_URI_NODIR, _uri._path);
// cmd line is: rsync [--port=PORT] source [user@]host::path // cmd line is: rsync [--port=PORT] source [user@]host::path
if (uri.port != "") if (_uri._port != "")
{ {
arguments.push_back ("--port=" + uri.port); _arguments.push_back ("--port=" + _uri._port);
} }
arguments.push_back (source); _arguments.push_back (source);
if (uri.user != "") if (_uri._user != "")
{ {
arguments.push_back (uri.user + "@" + uri.host + "::" + uri.path); _arguments.push_back (_uri._user + "@" + _uri._host + "::" + _uri._path);
} }
else else
{ {
arguments.push_back (uri.host + "::" + uri.path); _arguments.push_back (_uri._host + "::" + _uri._path);
} }
if (execute()) if (execute())
@@ -72,28 +72,28 @@ void TransportRSYNC::send(const std::string& source)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TransportRSYNC::recv(std::string target) void TransportRSYNC::recv(std::string target)
{ {
if (uri.host == "") if (_uri._host == "")
throw std::string (STRING_TRANSPORT_RSYNC_URI); throw std::string (STRING_TRANSPORT_RSYNC_URI);
// Is there more than one file to transfer? // Is there more than one file to transfer?
// Then target has to end with a '/' // Then target has to end with a '/'
if (is_filelist(uri.path) && !is_directory(target)) if (is_filelist(_uri._path) && !is_directory(target))
throw format (STRING_TRANSPORT_URI_NODIR, target); throw format (STRING_TRANSPORT_URI_NODIR, target);
// cmd line is: rsync [--port=PORT] [user@]host::path target // cmd line is: rsync [--port=PORT] [user@]host::path target
if (uri.port != "") if (_uri._port != "")
arguments.push_back ("--port=" + uri.port); _arguments.push_back ("--port=" + _uri._port);
if (uri.user != "") if (_uri._user != "")
{ {
arguments.push_back (uri.user + "@" + uri.host + "::" + uri.path); _arguments.push_back (_uri._user + "@" + _uri._host + "::" + _uri._path);
} }
else else
{ {
arguments.push_back (uri.host + "::" + uri.path); _arguments.push_back (_uri._host + "::" + _uri._path);
} }
arguments.push_back (target); _arguments.push_back (target);
if (execute()) if (execute())
throw std::string (STRING_TRANSPORT_RSYNC_NORUN); throw std::string (STRING_TRANSPORT_RSYNC_NORUN);

View File

@@ -34,36 +34,36 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
TransportSSH::TransportSSH(const Uri& uri) : Transport(uri) TransportSSH::TransportSSH(const Uri& uri) : Transport(uri)
{ {
executable = "scp"; _executable = "scp";
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TransportSSH::send(const std::string& source) void TransportSSH::send(const std::string& source)
{ {
if (uri.host == "") if (_uri._host == "")
throw std::string (STRING_TRANSPORT_SSH_URI); throw std::string (STRING_TRANSPORT_SSH_URI);
// Is there more than one file to transfer? // Is there more than one file to transfer?
// Then path has to end with a '/' // Then path has to end with a '/'
if (is_filelist(source) && !uri.is_directory()) if (is_filelist(source) && !_uri.is_directory())
throw format (STRING_TRANSPORT_URI_NODIR, uri.path); throw format (STRING_TRANSPORT_URI_NODIR, _uri._path);
// cmd line is: scp [-p port] [user@]host:path // cmd line is: scp [-p port] [user@]host:path
if (uri.port != "") if (_uri._port != "")
{ {
arguments.push_back ("-P"); _arguments.push_back ("-P");
arguments.push_back (uri.port); _arguments.push_back (_uri._port);
} }
arguments.push_back (source); _arguments.push_back (source);
if (uri.user != "") if (_uri._user != "")
{ {
arguments.push_back (uri.user + "@" + uri.host + ":" + uri.path); _arguments.push_back (_uri._user + "@" + _uri._host + ":" + _uri._path);
} }
else else
{ {
arguments.push_back (uri.host + ":" + uri.path); _arguments.push_back (_uri._host + ":" + _uri._path);
} }
if (execute()) if (execute())
@@ -73,31 +73,31 @@ void TransportSSH::send(const std::string& source)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void TransportSSH::recv(std::string target) void TransportSSH::recv(std::string target)
{ {
if (uri.host == "") if (_uri._host == "")
throw std::string (STRING_TRANSPORT_SSH_URI); throw std::string (STRING_TRANSPORT_SSH_URI);
// Is there more than one file to transfer? // Is there more than one file to transfer?
// Then target has to end with a '/' // Then target has to end with a '/'
if (is_filelist(uri.path) && !is_directory(target)) if (is_filelist(_uri._path) && !is_directory(target))
throw format (STRING_TRANSPORT_URI_NODIR, target); throw format (STRING_TRANSPORT_URI_NODIR, target);
// cmd line is: scp [-p port] [user@]host:path // cmd line is: scp [-p port] [user@]host:path
if (uri.port != "") if (_uri._port != "")
{ {
arguments.push_back ("-P"); _arguments.push_back ("-P");
arguments.push_back (uri.port); _arguments.push_back (_uri._port);
} }
if (uri.user != "") if (_uri._user != "")
{ {
arguments.push_back (uri.user + "@" + uri.host + ":" + uri.path); _arguments.push_back (_uri._user + "@" + _uri._host + ":" + _uri._path);
} }
else else
{ {
arguments.push_back (uri.host + ":" + uri.path); _arguments.push_back (_uri._host + ":" + _uri._path);
} }
arguments.push_back (target); _arguments.push_back (target);
if (execute()) if (execute())
throw std::string (STRING_TRANSPORT_SSH_NORUN); throw std::string (STRING_TRANSPORT_SSH_NORUN);

View File

@@ -37,7 +37,7 @@ extern Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Uri::Uri () Uri::Uri ()
{ {
parsed = false; _parsed = false;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -45,21 +45,21 @@ Uri::Uri (const Uri& other)
{ {
if (this != &other) if (this != &other)
{ {
data = other.data; _data = other._data;
host = other.host; _host = other._host;
path = other.path; _path = other._path;
user = other.user; _user = other._user;
port = other.port; _port = other._port;
protocol = other.protocol; _protocol = other._protocol;
parsed = other.parsed; _parsed = other._parsed;
} }
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Uri::Uri (const std::string& in, const std::string& configPrefix) Uri::Uri (const std::string& in, const std::string& configPrefix)
{ {
data = in; _data = in;
parsed = false; _parsed = false;
if (configPrefix != "") if (configPrefix != "")
expand(configPrefix); expand(configPrefix);
} }
@@ -74,13 +74,13 @@ Uri& Uri::operator= (const Uri& other)
{ {
if (this != &other) if (this != &other)
{ {
this->data = other.data; this->_data = other._data;
this->host = other.host; this->_host = other._host;
this->path = other.path; this->_path = other._path;
this->user = other.user; this->_user = other._user;
this->port = other.port; this->_port = other._port;
this->protocol = other.protocol; this->_protocol = other._protocol;
this->parsed = other.parsed; this->_parsed = other._parsed;
} }
return *this; return *this;
@@ -89,30 +89,30 @@ Uri& Uri::operator= (const Uri& other)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Uri::operator std::string () const Uri::operator std::string () const
{ {
return data; return _data;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Uri::name () const std::string Uri::name () const
{ {
if (path.length ()) if (_path.length ())
{ {
std::string::size_type slash = path.rfind ('/'); std::string::size_type slash = _path.rfind ('/');
if (slash != std::string::npos) if (slash != std::string::npos)
return path.substr (slash + 1, std::string::npos); return _path.substr (slash + 1, std::string::npos);
} }
return path; return _path;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Uri::parent () const std::string Uri::parent () const
{ {
if (path.length ()) if (_path.length ())
{ {
std::string::size_type slash = path.rfind ('/'); std::string::size_type slash = _path.rfind ('/');
if (slash != std::string::npos) if (slash != std::string::npos)
return path.substr (0, slash+1); return _path.substr (0, slash+1);
} }
return ""; return "";
@@ -121,11 +121,11 @@ std::string Uri::parent () const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string Uri::extension () const std::string Uri::extension () const
{ {
if (path.length ()) if (_path.length ())
{ {
std::string::size_type dot = path.rfind ('.'); std::string::size_type dot = _path.rfind ('.');
if (dot != std::string::npos) if (dot != std::string::npos)
return path.substr (dot + 1, std::string::npos); return _path.substr (dot + 1, std::string::npos);
} }
return ""; return "";
@@ -135,21 +135,21 @@ std::string Uri::extension () const
bool Uri::is_directory () const bool Uri::is_directory () const
{ {
if (is_local ()) { if (is_local ()) {
return Path (this->data).is_directory (); return Path (this->_data).is_directory ();
} else } else
return (path == ".") return (_path == ".")
|| (path == "") || (_path == "")
|| (path[path.length()-1] == '/'); || (_path[_path.length()-1] == '/');
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool Uri::is_local () const bool Uri::is_local () const
{ {
if (parsed) if (_parsed)
return (protocol == ""); return (_protocol == "");
else else
return ( (data.find("://") == std::string::npos) return ( (_data.find("://") == std::string::npos)
&& (data.find(":") == std::string::npos) ); && (_data.find(":") == std::string::npos) );
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -157,7 +157,7 @@ bool Uri::append (const std::string& path)
{ {
if (is_directory ()) if (is_directory ())
{ {
this->path += path; this->_path += path;
return true; return true;
} }
else else
@@ -168,10 +168,10 @@ bool Uri::append (const std::string& path)
bool Uri::expand (const std::string& configPrefix ) bool Uri::expand (const std::string& configPrefix )
{ {
std::string tmp; std::string tmp;
if (data.length ()) if (_data.length ())
{ {
// try to replace argument with uri from config // try to replace argument with uri from config
tmp = context.config.get (configPrefix + "." + data + ".uri"); tmp = context.config.get (configPrefix + "." + _data + ".uri");
} }
else else
{ {
@@ -181,7 +181,7 @@ bool Uri::expand (const std::string& configPrefix )
if (tmp != "") if (tmp != "")
{ {
data = tmp; _data = tmp;
return true; return true;
} }
@@ -191,90 +191,90 @@ bool Uri::expand (const std::string& configPrefix )
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void Uri::parse () void Uri::parse ()
{ {
if (parsed) if (_parsed)
return; return;
if (is_local ()) if (is_local ())
{ {
path = data; _path = _data;
parsed = true; _parsed = true;
return; return;
} }
std::string::size_type pos; std::string::size_type pos;
std::string data = this->data; std::string _data = this->_data;
std::string pathDelimiter = "/"; std::string pathDelimiter = "/";
user = ""; _user = "";
port = ""; _port = "";
// skip ^.*:// // skip ^.*://
if ((pos = data.find ("://")) != std::string::npos) if ((pos = _data.find ("://")) != std::string::npos)
{ {
protocol = data.substr(0, pos); _protocol = _data.substr(0, pos);
data = data.substr (pos+3); _data = _data.substr (pos+3);
// standard syntax: protocol://[user@]host.xz[:port]/path/to/undo.data // standard syntax: protocol://[user@]host.xz[:port]/path/to/undo.data
pathDelimiter = "/"; pathDelimiter = "/";
} }
else else
{ {
protocol = "ssh"; _protocol = "ssh";
// scp-like syntax: [user@]host.xz:path/to/undo.data // scp-like syntax: [user@]host.xz:path/to/undo.data
pathDelimiter = ":"; pathDelimiter = ":";
} }
// user delimited by single quotes? // user delimited by single quotes?
if ( data[0] == '\'' if ( _data[0] == '\''
&& (pos = data.find("'", 1)) != std::string::npos ) && (pos = _data.find("'", 1)) != std::string::npos )
{ {
if (data[pos+1] == '@') if (_data[pos+1] == '@')
{ {
// end of user name // end of user name
user = data.substr (1, pos-1); _user = _data.substr (1, pos-1);
data = data.substr (pos+2); _data = _data.substr (pos+2);
} }
else else
{ {
throw std::string (format (STRING_URI_QUOTES, data)); throw std::string (format (STRING_URI_QUOTES, _data));
} }
} }
else else
{ {
// find user name // find user name
if ((pos = data.find ("@")) != std::string::npos) if ((pos = _data.find ("@")) != std::string::npos)
{ {
user = data.substr (0, pos); _user = _data.substr (0, pos);
data = data.substr (pos+1); _data = _data.substr (pos+1);
} }
} }
// get host, port and path // get host, port and path
if ((pos = data.find (pathDelimiter)) != std::string::npos) if ((pos = _data.find (pathDelimiter)) != std::string::npos)
{ {
host = data.substr (0, pos); _host = _data.substr (0, pos);
path = data.substr (pos+1); _path = _data.substr (pos+1);
} }
else else
{ {
throw std::string (format (STRING_URI_BAD_FORMAT, data)); throw std::string (format (STRING_URI_BAD_FORMAT, _data));
} }
// path is absolute for ssh:// syntax // path is absolute for ssh:// syntax
if ( (protocol == "ssh") && (pathDelimiter == "/") ) if ( (_protocol == "ssh") && (pathDelimiter == "/") )
{ {
path = "/" + path; _path = "/" + _path;
} }
// port specified? // port specified?
// remark: this find() will never be != npos for scp-like syntax // remark: this find() will never be != npos for scp-like syntax
// because we found pathDelimiter, which is ":", before // because we found pathDelimiter, which is ":", before
if ((pos = host.find (":")) != std::string::npos) if ((pos = _host.find (":")) != std::string::npos)
{ {
port = host.substr (pos+1); _port = _host.substr (pos+1);
host = host.substr (0,pos); _host = _host.substr (0,pos);
} }
parsed = true; _parsed = true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@@ -57,13 +57,13 @@ public:
void parse (); void parse ();
public: public:
std::string data; std::string _data;
std::string path; std::string _path;
std::string host; std::string _host;
std::string port; std::string _port;
std::string user; std::string _user;
std::string protocol; std::string _protocol;
bool parsed; bool _parsed;
}; };
#endif #endif

View File

@@ -79,7 +79,7 @@ int CmdConfig::execute (std::string& output)
// Read .taskrc (or equivalent) // Read .taskrc (or equivalent)
std::vector <std::string> contents; std::vector <std::string> contents;
File::read (context.config.original_file, contents); File::read (context.config._original_file, contents);
// task config name value // task config name value
// task config name "" // task config name ""
@@ -157,9 +157,9 @@ int CmdConfig::execute (std::string& output)
// Write .taskrc (or equivalent) // Write .taskrc (or equivalent)
if (change) if (change)
{ {
File::write (context.config.original_file, contents); File::write (context.config._original_file, contents);
out << "Config file " out << "Config file "
<< context.config.original_file.data << context.config._original_file._data
<< " modified.\n"; << " modified.\n";
} }
else else

View File

@@ -178,17 +178,17 @@ int CmdDiagnostics::execute (std::string& output)
// Config: .taskrc found, readable, writable // Config: .taskrc found, readable, writable
out << bold.colorize ("Configuration") out << bold.colorize ("Configuration")
<< "\n" << "\n"
<< " File: " << context.config.original_file.data << " File: " << context.config._original_file._data
<< (context.config.original_file.exists () ? " (found)" : " (missing)") << (context.config._original_file.exists () ? " (found)" : " (missing)")
<< ", " << context.config.original_file.size () << " bytes" << ", " << context.config._original_file.size () << " bytes"
<< ", mode " << ", mode "
<< std::setbase (8) << std::setbase (8)
<< context.config.original_file.mode () << context.config._original_file.mode ()
<< "\n"; << "\n";
// Config: data.location found, readable, writable // Config: data.location found, readable, writable
File location (context.config.get ("data.location")); File location (context.config.get ("data.location"));
out << " Data: " << location.data out << " Data: " << location._data
<< (location.exists () ? " (found)" : " (missing)") << (location.exists () ? " (found)" : " (missing)")
<< ", " << (location.is_directory () ? "dir" : "?") << ", " << (location.is_directory () ? "dir" : "?")
<< ", mode " << ", mode "

View File

@@ -600,11 +600,11 @@ bool CmdEdit::editFile (Task& task)
// Create a temp file name in data.location. // Create a temp file name in data.location.
std::stringstream file; std::stringstream file;
file << "task." << getpid () << "." << task.id << ".task"; file << "task." << getpid () << "." << task.id << ".task";
std::string path = location.data + "/" + file.str (); std::string path = location._data + "/" + file.str ();
// Format the contents, T -> text, write to a file. // Format the contents, T -> text, write to a file.
std::string before = formatTask (task); std::string before = formatTask (task);
int ignored = chdir (location.data.c_str ()); int ignored = chdir (location._data.c_str ());
++ignored; // Keep compiler quiet. ++ignored; // Keep compiler quiet.
File::write (file.str (), before); File::write (file.str (), before);

View File

@@ -77,7 +77,7 @@ int CmdInfo::execute (std::string& output)
if (context.config.getBoolean ("journal.info")) if (context.config.getBoolean ("journal.info"))
{ {
Directory location (context.config.get ("data.location")); Directory location (context.config.get ("data.location"));
std::string undoFile = location.data + "/undo.data"; std::string undoFile = location._data + "/undo.data";
File::read (undoFile, undo); File::read (undoFile, undo);
} }

View File

@@ -63,7 +63,7 @@ int CmdMerge::execute (std::string& output)
Uri uri (file, "merge"); Uri uri (file, "merge");
uri.parse(); uri.parse();
if (uri.data.length ()) if (uri._data.length ())
{ {
Directory location (context.config.get ("data.location")); Directory location (context.config.get ("data.location"));
@@ -73,14 +73,14 @@ int CmdMerge::execute (std::string& output)
Transport* transport; Transport* transport;
if ((transport = Transport::getTransport (uri)) != NULL ) if ((transport = Transport::getTransport (uri)) != NULL )
{ {
tmpfile = location.data + "/undo_remote.data"; tmpfile = location._data + "/undo_remote.data";
transport->recv (tmpfile); transport->recv (tmpfile);
delete transport; delete transport;
file = tmpfile; file = tmpfile;
} }
else else
file = uri.path; file = uri._path;
context.tdb.lock (context.config.getBoolean ("locking")); context.tdb.lock (context.config.getBoolean ("locking"));
context.tdb.merge (file); context.tdb.merge (file);
@@ -91,10 +91,10 @@ int CmdMerge::execute (std::string& output)
if (tmpfile != "") if (tmpfile != "")
remove (tmpfile.c_str ()); remove (tmpfile.c_str ());
if ( ((sAutopush == "ask") && (confirm ("Would you like to push the merged changes to \'" + uri.data + "\'?")) ) if ( ((sAutopush == "ask") && (confirm ("Would you like to push the merged changes to \'" + uri._data + "\'?")) )
|| (bAutopush) ) || (bAutopush) )
{ {
// context.task.set ("description", uri.data); // context.task.set ("description", uri._data);
std::string out; std::string out;
context.commands["push"]->execute (out); context.commands["push"]->execute (out);

View File

@@ -56,59 +56,59 @@ int CmdPull::execute (std::string& output)
Uri uri (file, "pull"); Uri uri (file, "pull");
uri.parse (); uri.parse ();
if (uri.data.length ()) if (uri._data.length ())
{ {
Directory location (context.config.get ("data.location")); Directory location (context.config.get ("data.location"));
if (! uri.append ("{pending,undo,completed}.data")) if (! uri.append ("{pending,undo,completed}.data"))
throw std::string ("The uri '") + uri.path + "' is not a directory. Did you forget a trailing '/'?"; throw std::string ("The uri '") + uri._path + "' is not a directory. Did you forget a trailing '/'?";
Transport* transport; Transport* transport;
if ((transport = Transport::getTransport (uri)) != NULL) if ((transport = Transport::getTransport (uri)) != NULL)
{ {
transport->recv (location.data + "/"); transport->recv (location._data + "/");
delete transport; delete transport;
} }
else else
{ {
// Verify that files are not being copied from rc.data.location to the // Verify that files are not being copied from rc.data.location to the
// same place. // same place.
if (Directory (uri.path) == Directory (context.config.get ("data.location"))) if (Directory (uri._path) == Directory (context.config.get ("data.location")))
throw std::string ("Cannot pull files when the source and destination are the same."); throw std::string ("Cannot pull files when the source and destination are the same.");
// copy files locally // copy files locally
// remove {pending,undo,completed}.data // remove {pending,undo,completed}.data
uri.path = uri.parent(); uri._path = uri.parent();
Path path1 (uri.path + "undo.data"); Path path1 (uri._path + "undo.data");
Path path2 (uri.path + "pending.data"); Path path2 (uri._path + "pending.data");
Path path3 (uri.path + "completed.data"); Path path3 (uri._path + "completed.data");
if (path1.exists() && path2.exists() && path3.exists()) if (path1.exists() && path2.exists() && path3.exists())
{ {
// if (confirm ("xxxxxxxxxxxxx")) // if (confirm ("xxxxxxxxxxxxx"))
// { // {
std::ofstream ofile1 ((location.data + "/undo.data").c_str(), std::ios_base::binary); std::ofstream ofile1 ((location._data + "/undo.data").c_str(), std::ios_base::binary);
std::ifstream ifile1 (path1.data.c_str() , std::ios_base::binary); std::ifstream ifile1 (path1._data.c_str() , std::ios_base::binary);
ofile1 << ifile1.rdbuf(); ofile1 << ifile1.rdbuf();
std::ofstream ofile2 ((location.data + "/pending.data").c_str(), std::ios_base::binary); std::ofstream ofile2 ((location._data + "/pending.data").c_str(), std::ios_base::binary);
std::ifstream ifile2 (path2.data.c_str() , std::ios_base::binary); std::ifstream ifile2 (path2._data.c_str() , std::ios_base::binary);
ofile2 << ifile2.rdbuf(); ofile2 << ifile2.rdbuf();
std::ofstream ofile3 ((location.data + "/completed.data").c_str(), std::ios_base::binary); std::ofstream ofile3 ((location._data + "/completed.data").c_str(), std::ios_base::binary);
std::ifstream ifile3 (path3.data.c_str() , std::ios_base::binary); std::ifstream ifile3 (path3._data.c_str() , std::ios_base::binary);
ofile3 << ifile3.rdbuf(); ofile3 << ifile3.rdbuf();
// } // }
} }
else else
{ {
throw std::string ("At least one of the database files in '" + uri.path + "' is not present."); throw std::string ("At least one of the database files in '" + uri._path + "' is not present.");
} }
} }
output += "Tasks transferred from " + uri.data + "\n"; output += "Tasks transferred from " + uri._data + "\n";
} }
else else
throw std::string ("No uri was specified for the pull. Either specify " throw std::string ("No uri was specified for the pull. Either specify "

View File

@@ -46,7 +46,7 @@ CmdPush::CmdPush ()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Transfers the local data (from rc.location.data) to the remote path. Because // Transfers the local data (from rc.location._data) to the remote path. Because
// this is potentially on another machine, no checking can be performed. // this is potentially on another machine, no checking can be performed.
int CmdPush::execute (std::string& output) int CmdPush::execute (std::string& output)
{ {
@@ -58,41 +58,41 @@ int CmdPush::execute (std::string& output)
Uri uri (file, "push"); Uri uri (file, "push");
uri.parse (); uri.parse ();
if (uri.data.length ()) if (uri._data.length ())
{ {
Directory location (context.config.get ("data.location")); Directory location (context.config.get ("data.location"));
Transport* transport; Transport* transport;
if ((transport = Transport::getTransport (uri)) != NULL ) if ((transport = Transport::getTransport (uri)) != NULL )
{ {
transport->send (location.data + "/{pending,undo,completed}.data"); transport->send (location._data + "/{pending,undo,completed}.data");
delete transport; delete transport;
} }
else else
{ {
// Verify that files are not being copied from rc.data.location to the // Verify that files are not being copied from rc.data.location to the
// same place. // same place.
if (Directory (uri.path) == Directory (context.config.get ("data.location"))) if (Directory (uri._path) == Directory (context.config.get ("data.location")))
throw std::string ("Cannot push files when the source and destination are the same."); throw std::string ("Cannot push files when the source and destination are the same.");
// copy files locally // copy files locally
if (! Path (uri.data).is_directory ()) if (! Path (uri._data).is_directory ())
throw std::string ("The uri '") + uri.path + "' is not a local directory."; throw std::string ("The uri '") + uri._path + "' is not a local directory.";
std::ifstream ifile1 ((location.data + "/undo.data").c_str(), std::ios_base::binary); std::ifstream ifile1 ((location._data + "/undo.data").c_str(), std::ios_base::binary);
std::ofstream ofile1 ((uri.path + "/undo.data").c_str(), std::ios_base::binary); std::ofstream ofile1 ((uri._path + "/undo.data").c_str(), std::ios_base::binary);
ofile1 << ifile1.rdbuf(); ofile1 << ifile1.rdbuf();
std::ifstream ifile2 ((location.data + "/pending.data").c_str(), std::ios_base::binary); std::ifstream ifile2 ((location._data + "/pending.data").c_str(), std::ios_base::binary);
std::ofstream ofile2 ((uri.path + "/pending.data").c_str(), std::ios_base::binary); std::ofstream ofile2 ((uri._path + "/pending.data").c_str(), std::ios_base::binary);
ofile2 << ifile2.rdbuf(); ofile2 << ifile2.rdbuf();
std::ifstream ifile3 ((location.data + "/completed.data").c_str(), std::ios_base::binary); std::ifstream ifile3 ((location._data + "/completed.data").c_str(), std::ios_base::binary);
std::ofstream ofile3 ((uri.path + "/completed.data").c_str(), std::ios_base::binary); std::ofstream ofile3 ((uri._path + "/completed.data").c_str(), std::ios_base::binary);
ofile3 << ifile3.rdbuf(); ofile3 << ifile3.rdbuf();
} }
output += "Local tasks transferred to " + uri.data + "\n"; output += "Local tasks transferred to " + uri._data + "\n";
} }
else else
throw std::string ("No uri was specified for the push. Either specify " throw std::string ("No uri was specified for the push. Either specify "

View File

@@ -410,7 +410,7 @@ int CmdShow::execute (std::string& output)
{ {
Directory location (context.config.get ("data.location")); Directory location (context.config.get ("data.location"));
if (location.data == "") if (location._data == "")
out << STRING_CMD_SHOW_NO_LOCATION << "\n"; out << STRING_CMD_SHOW_NO_LOCATION << "\n";
if (! location.exists ()) if (! location.exists ())

View File

@@ -63,13 +63,13 @@ int CmdStatistics::execute (std::string& output)
size_t dataSize = 0; size_t dataSize = 0;
Directory location (context.config.get ("data.location")); Directory location (context.config.get ("data.location"));
File pending (location.data + "/pending.data"); File pending (location._data + "/pending.data");
dataSize += pending.size (); dataSize += pending.size ();
File completed (location.data + "/completed.data"); File completed (location._data + "/completed.data");
dataSize += completed.size (); dataSize += completed.size ();
File undo (location.data + "/undo.data"); File undo (location._data + "/undo.data");
dataSize += undo.size (); dataSize += undo.size ();
std::vector <std::string> undoTxns; std::vector <std::string> undoTxns;

1
test/.gitignore vendored
View File

@@ -24,7 +24,6 @@ rx.t
sensor.t sensor.t
seq.t seq.t
subst.t subst.t
t.benchmark.t
t.t t.t
t2.t t2.t
taskmod.t taskmod.t

View File

@@ -8,8 +8,8 @@ include_directories (${CMAKE_SOURCE_DIR}
set (test_SRCS att.t autocomplete.t color.t config.t date.t directory.t dom.t set (test_SRCS att.t autocomplete.t color.t config.t date.t directory.t dom.t
duration.t file.t i18n.t json.t list.t nibbler.t path.t rx.t duration.t file.t i18n.t json.t list.t nibbler.t path.t rx.t
t.benchmark.t t.t t2.t taskmod.t tdb.t tdb2.t text.t uri.t util.t t.t t2.t taskmod.t tdb.t tdb2.t text.t uri.t util.t view.t
view.t json_test) json_test)
add_custom_target (test ./run_all DEPENDS ${test_SRCS} add_custom_target (test ./run_all DEPENDS ${test_SRCS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)

View File

@@ -41,20 +41,20 @@ int main (int argc, char** argv)
Directory d0 (Path ("/tmp")); Directory d0 (Path ("/tmp"));
Directory d1 (File ("/tmp")); Directory d1 (File ("/tmp"));
Directory d2 (File (Path ("/tmp"))); Directory d2 (File (Path ("/tmp")));
t.is (d0.data, d1.data, "Directory(std::string) == Directory (File&)"); t.is (d0._data, d1._data, "Directory(std::string) == Directory (File&)");
t.is (d0.data, d2.data, "Directory(std::string) == Directory (File (Path &))"); t.is (d0._data, d2._data, "Directory(std::string) == Directory (File (Path &))");
t.is (d1.data, d2.data, "Directory(File&)) == Directory (File (Path &))"); t.is (d1._data, d2._data, "Directory(File&)) == Directory (File (Path &))");
// Directory (const Directory&); // Directory (const Directory&);
Directory d3 (d2); Directory d3 (d2);
t.is (d3.data, "/tmp", "Directory (Directory&)"); t.is (d3._data, "/tmp", "Directory (Directory&)");
// Directory (const std::string&); // Directory (const std::string&);
Directory d4 ("/tmp/test_directory"); Directory d4 ("/tmp/test_directory");
// Directory& operator= (const Directory&); // Directory& operator= (const Directory&);
Directory d5 = d4; Directory d5 = d4;
t.is (d5.data, "/tmp/test_directory", "Directory::operator="); t.is (d5._data, "/tmp/test_directory", "Directory::operator=");
// operator (std::string) const; // operator (std::string) const;
t.is ((std::string) d3, "/tmp", "Directory::operator (std::string) const"); t.is ((std::string) d3, "/tmp", "Directory::operator (std::string) const");
@@ -63,11 +63,11 @@ int main (int argc, char** argv)
t.ok (d5.create (), "Directory::create /tmp/test_directory"); t.ok (d5.create (), "Directory::create /tmp/test_directory");
t.ok (d5.exists (), "Directory::exists /tmp/test_directory"); t.ok (d5.exists (), "Directory::exists /tmp/test_directory");
Directory d6 (d5.data + "/dir"); Directory d6 (d5._data + "/dir");
t.ok (d6.create (), "Directory::create /tmp/test_directory/dir"); t.ok (d6.create (), "Directory::create /tmp/test_directory/dir");
File::create (d5.data + "/f0"); File::create (d5._data + "/f0");
File::create (d6.data + "/f1"); File::create (d6._data + "/f1");
// std::vector <std::string> list (); // std::vector <std::string> list ();
std::vector <std::string> files = d5.list (); std::vector <std::string> files = d5.list ();
@@ -84,8 +84,8 @@ int main (int argc, char** argv)
t.is (files[1], "/tmp/test_directory/f0", "file is /tmp/test_directory/f0"); t.is (files[1], "/tmp/test_directory/f0", "file is /tmp/test_directory/f0");
// virtual bool remove (); // virtual bool remove ();
t.ok (File::remove (d5.data + "/f0"), "File::remove /tmp/test_directory/f0"); t.ok (File::remove (d5._data + "/f0"), "File::remove /tmp/test_directory/f0");
t.ok (File::remove (d6.data + "/f1"), "File::remove /tmp/test_directory/dir/f1"); t.ok (File::remove (d6._data + "/f1"), "File::remove /tmp/test_directory/dir/f1");
t.ok (d6.remove (), "Directory::remove /tmp/test_directory/dir"); t.ok (d6.remove (), "Directory::remove /tmp/test_directory/dir");
t.notok (d6.exists (), "Directory::exists /tmp/test_directory/dir - no"); t.notok (d6.exists (), "Directory::exists /tmp/test_directory/dir - no");
@@ -96,10 +96,10 @@ int main (int argc, char** argv)
// bool remove (const std::string&); // bool remove (const std::string&);
Directory d7 ("/tmp/to_be_removed"); Directory d7 ("/tmp/to_be_removed");
t.ok (d7.create (), "Directory::create /tmp/to_be_removed"); t.ok (d7.create (), "Directory::create /tmp/to_be_removed");
File::create (d7.data + "/f0"); File::create (d7._data + "/f0");
Directory d8 (d7.data + "/another"); Directory d8 (d7._data + "/another");
t.ok (d8.create (), "Directory::create /tmp/to_be_removed/another"); t.ok (d8.create (), "Directory::create /tmp/to_be_removed/another");
File::create (d8.data + "/f1"); File::create (d8._data + "/f1");
t.ok (d7.remove (), "Directory::remove /tmp/to_be_removed"); t.ok (d7.remove (), "Directory::remove /tmp/to_be_removed");
t.notok (d7.exists (), "Directory /tmp/to_be_removed gone"); t.notok (d7.exists (), "Directory /tmp/to_be_removed gone");

View File

@@ -37,22 +37,22 @@ int main (int argc, char** argv)
// Path (); // Path ();
Path p0; Path p0;
t.ok (p0.data == "", "Path::Path"); t.ok (p0._data == "", "Path::Path");
// Path (const Path&); // Path (const Path&);
Path p1 = Path ("foo"); Path p1 = Path ("foo");
t.ok (p1.data == "foo", "Path::operator="); t.ok (p1._data == "foo", "Path::operator=");
// Path (const std::string&); // Path (const std::string&);
Path p2 ("~"); Path p2 ("~");
t.ok (p2.data != "~", "~ expanded to " + p2.data); t.ok (p2._data != "~", "~ expanded to " + p2._data);
Path p3 ("/tmp"); Path p3 ("/tmp");
t.ok (p3.data == "/tmp", "/tmp -> /tmp"); t.ok (p3._data == "/tmp", "/tmp -> /tmp");
// Path& operator= (const Path&); // Path& operator= (const Path&);
Path p3_copy (p3); Path p3_copy (p3);
t.is (p3.data, p3_copy.data, "Path::Path (Path&)"); t.is (p3._data, p3_copy._data, "Path::Path (Path&)");
// operator (std::string) const; // operator (std::string) const;
t.is ((std::string) p3, "/tmp", "Path::operator (std::string) const"); t.is ((std::string) p3, "/tmp", "Path::operator (std::string) const");

View File

@@ -39,41 +39,41 @@ int main (int argc, char** argv)
Uri uri1 ("asfd://user@host/folder/"); Uri uri1 ("asfd://user@host/folder/");
uri1.parse (); uri1.parse ();
t.is (uri1.user, "user", "Uri::parse() : asdf://user@host/folder/"); t.is (uri1._user, "user", "Uri::parse() : asdf://user@host/folder/");
t.is (uri1.host, "host", "Uri::parse() : asdf://user@host/folder/"); t.is (uri1._host, "host", "Uri::parse() : asdf://user@host/folder/");
t.is (uri1.port, "", "Uri::parse() : asdf://user@host/folder/"); t.is (uri1._port, "", "Uri::parse() : asdf://user@host/folder/");
t.is (uri1.path, "folder/", "Uri::parse() : asdf://user@host/folder/"); t.is (uri1._path, "folder/", "Uri::parse() : asdf://user@host/folder/");
t.is (uri1.protocol, "asfd", "Uri::parse() : asdf://user@host/folder/"); t.is (uri1._protocol, "asfd", "Uri::parse() : asdf://user@host/folder/");
t.ok (uri1.append ("file.test"), "Uri::append() to path"); t.ok (uri1.append ("file.test"), "Uri::append() to path");
t.is (uri1.path, "folder/file.test", "Uri::append() ok"); t.is (uri1._path, "folder/file.test", "Uri::append() ok");
Uri uri2 ("user@host:folder/file.test"); Uri uri2 ("user@host:folder/file.test");
uri2.parse (); uri2.parse ();
t.is (uri2.user, "user", "Uri::parse() : user@host:folder/file.test"); t.is (uri2._user, "user", "Uri::parse() : user@host:folder/file.test");
t.is (uri2.host, "host", "Uri::parse() : user@host:folder/file.test"); t.is (uri2._host, "host", "Uri::parse() : user@host:folder/file.test");
t.is (uri2.port, "", "Uri::parse() : user@host/folder/file.test"); t.is (uri2._port, "", "Uri::parse() : user@host/folder/file.test");
t.is (uri2.path, "folder/file.test", "Uri::parse() : user@host/folder/file.test"); t.is (uri2._path, "folder/file.test", "Uri::parse() : user@host/folder/file.test");
t.is (uri2.protocol, "ssh", "Uri::parse() : user@host/folder/file.test"); t.is (uri2._protocol, "ssh", "Uri::parse() : user@host/folder/file.test");
t.notok (uri2.append ("test.dat"), "Uri::append() to file"); t.notok (uri2.append ("test.dat"), "Uri::append() to file");
Uri uri3 ("rsync://hostname.abc.de:1234//abs/path"); Uri uri3 ("rsync://hostname.abc.de:1234//abs/path");
uri3.parse (); uri3.parse ();
t.is (uri3.user, "", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path"); t.is (uri3._user, "", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
t.is (uri3.host, "hostname.abc.de", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path"); t.is (uri3._host, "hostname.abc.de", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
t.is (uri3.port, "1234", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path"); t.is (uri3._port, "1234", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
t.is (uri3.path, "/abs/path", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path"); t.is (uri3._path, "/abs/path", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
t.is (uri3.protocol, "rsync", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path"); t.is (uri3._protocol, "rsync", "Uri::parse() : rsync://hostname.abc.de:1234//abs/path");
Uri uri4 ("hostname:"); Uri uri4 ("hostname:");
uri4.parse (); uri4.parse ();
t.is (uri4.user, "", "Uri::parse() : hostname:"); t.is (uri4._user, "", "Uri::parse() : hostname:");
t.is (uri4.host, "hostname", "Uri::parse() : hostname:"); t.is (uri4._host, "hostname", "Uri::parse() : hostname:");
t.is (uri4.port, "", "Uri::parse() : hostname:"); t.is (uri4._port, "", "Uri::parse() : hostname:");
t.is (uri4.path, "", "Uri::parse() : hostname:"); t.is (uri4._path, "", "Uri::parse() : hostname:");
t.is (uri4.protocol, "ssh", "Uri::parse() : hostname:"); t.is (uri4._protocol, "ssh", "Uri::parse() : hostname:");
t.notok (uri4.is_local (), "Uri::is_local() : hostname:"); t.notok (uri4.is_local (), "Uri::is_local() : hostname:");
t.ok (uri4.append ("file.test"), "Uri::append() : hostname:"); t.ok (uri4.append ("file.test"), "Uri::append() : hostname:");
t.is (uri4.path, "file.test","Uri::append() : ok"); t.is (uri4._path, "file.test","Uri::append() : ok");
context.config.set ("merge.default.uri", "../folder/"); context.config.set ("merge.default.uri", "../folder/");
context.config.set ("push.test.uri", "/home/user/.task/"); context.config.set ("push.test.uri", "/home/user/.task/");
@@ -81,53 +81,52 @@ int main (int argc, char** argv)
Uri uri5 ("", "merge"); Uri uri5 ("", "merge");
t.ok (uri5.is_local (), "Uri::is_local() : ../server/"); t.ok (uri5.is_local (), "Uri::is_local() : ../server/");
uri5.parse (); uri5.parse ();
t.is (uri5.path, "../folder/", "Uri::expand() default"); t.is (uri5._path, "../folder/", "Uri::expand() default");
Uri uri6 ("test", "push"); Uri uri6 ("test", "push");
t.ok (uri6.is_local(), "Uri::is_local() : /home/user/.task/"); t.ok (uri6.is_local(), "Uri::is_local() : /home/user/.task/");
uri6.parse (); uri6.parse ();
t.is (uri6.path, "/home/user/.task/", "Uri::expand() test"); t.is (uri6._path, "/home/user/.task/", "Uri::expand() test");
Uri uri7 ("ftp://'user@name'@host:321/path/to/x"); Uri uri7 ("ftp://'user@name'@host:321/path/to/x");
uri7.parse (); uri7.parse ();
t.is (uri7.user, "user@name", "Uri::parse() : ftp://'user@name'@host:321/path/to/x"); t.is (uri7._user, "user@name", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
t.is (uri7.host, "host", "Uri::parse() : ftp://'user@name'@host:321/path/to/x"); t.is (uri7._host, "host", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
t.is (uri7.port, "321", "Uri::parse() : ftp://'user@name'@host:321/path/to/x"); t.is (uri7._port, "321", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
t.is (uri7.path, "path/to/x", "Uri::parse() : ftp://'user@name'@host:321/path/to/x"); t.is (uri7._path, "path/to/x", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
t.is (uri7.protocol, "ftp", "Uri::parse() : ftp://'user@name'@host:321/path/to/x"); t.is (uri7._protocol, "ftp", "Uri::parse() : ftp://'user@name'@host:321/path/to/x");
Uri uri8 ("http://'us/er@n:ame'@host/path/to/x"); Uri uri8 ("http://'us/er@n:ame'@host/path/to/x");
uri8.parse (); uri8.parse ();
t.is (uri8.user, "us/er@n:ame", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x"); t.is (uri8._user, "us/er@n:ame", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
t.is (uri8.host, "host", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x"); t.is (uri8._host, "host", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
t.is (uri8.port, "", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x"); t.is (uri8._port, "", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
t.is (uri8.path, "path/to/x", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x"); t.is (uri8._path, "path/to/x", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
t.is (uri8.protocol, "http", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x"); t.is (uri8._protocol, "http", "Uri::parse() : http://'us/er@n:ame'@host/path/to/x");
Uri uri9 ("'user@name'@host:path/to/x"); Uri uri9 ("'user@name'@host:path/to/x");
uri9.parse (); uri9.parse ();
t.is (uri9.user, "user@name", "Uri::parse() : 'user@name'@host:path/to/x"); t.is (uri9._user, "user@name", "Uri::parse() : 'user@name'@host:path/to/x");
t.is (uri9.host, "host", "Uri::parse() : 'user@name'@host:path/to/x"); t.is (uri9._host, "host", "Uri::parse() : 'user@name'@host:path/to/x");
t.is (uri9.port, "", "Uri::parse() : 'user@name'@host:path/to/x"); t.is (uri9._port, "", "Uri::parse() : 'user@name'@host:path/to/x");
t.is (uri9.path, "path/to/x", "Uri::parse() : 'user@name'@host:path/to/x"); t.is (uri9._path, "path/to/x", "Uri::parse() : 'user@name'@host:path/to/x");
// bug #668 // bug #668
Uri uri10 ("user.name@host.com:undo.data"); Uri uri10 ("user.name@host.com:undo.data");
uri10.parse (); uri10.parse ();
t.is (uri10.user, "user.name", "Uri::parse() : user.name@host.com:undo.data"); t.is (uri10._user, "user.name", "Uri::parse() : user.name@host.com:undo.data");
t.is (uri10.host, "host.com", "Uri::parse() : user.name@host.com:undo.data"); t.is (uri10._host, "host.com", "Uri::parse() : user.name@host.com:undo.data");
t.is (uri10.port, "", "Uri::parse() : user.name@host.com:undo.data"); t.is (uri10._port, "", "Uri::parse() : user.name@host.com:undo.data");
t.is (uri10.path, "undo.data", "Uri::parse() : user.name@host.com:undo.data"); t.is (uri10._path, "undo.data", "Uri::parse() : user.name@host.com:undo.data");
t.is (uri10.protocol, "ssh", "Uri::parse() : user.name@host.com:undo.data"); t.is (uri10._protocol, "ssh", "Uri::parse() : user.name@host.com:undo.data");
Uri uri11 ("ssh://user.name@host.com/undo.data"); Uri uri11 ("ssh://user.name@host.com/undo.data");
uri11.parse (); uri11.parse ();
t.is (uri11.user, "user.name", "Uri::parse() : ssh://user.name@host.com/undo.data"); t.is (uri11._user, "user.name", "Uri::parse() : ssh://user.name@host.com/undo.data");
t.is (uri11.host, "host.com", "Uri::parse() : ssh://user.name@host.com/undo.data"); t.is (uri11._host, "host.com", "Uri::parse() : ssh://user.name@host.com/undo.data");
t.is (uri11.port, "", "Uri::parse() : ssh://user.name@host.com/undo.data"); t.is (uri11._port, "", "Uri::parse() : ssh://user.name@host.com/undo.data");
t.is (uri11.path, "/undo.data", "Uri::parse() : ssh://user.name@host.com/undo.data"); t.is (uri11._path, "/undo.data", "Uri::parse() : ssh://user.name@host.com/undo.data");
t.is (uri11.protocol, "ssh", "Uri::parse() : ssh://user.name@host.com/undo.data"); t.is (uri11._protocol, "ssh", "Uri::parse() : ssh://user.name@host.com/undo.data");
return 0; return 0;
} }