Code Cleanup
- Cmake was not updating HAVE_ST_BIRTHTIME.
- NIBBLER_FEATURE_DATE was not properly applied everywhere.
- FEATURE_COLOR was not properly set.
- Some source files failed to include cmake.h, and therefore were not properly
- Removed inefficient use of std::string::substr for guaranteed single character
strings.
- Integrated Directory::cd.
- Integrated File::ctime, ::btime.
- Integrated Path::operator+.
- Integrated Nibbler::getDigit{2,4,6}.
- Integrated HighResTimer.
enabling/disabling code.
- All Path objects now expanded internally to absolute form.
- Modified unit tests to accomodate absolute paths.
- Merged new nibbler.t.cpp tests.
- Made various methods const.
- Includes removed from some files, added to others.
This commit is contained in:
@@ -294,6 +294,69 @@ bool Nibbler::getDigit (int& result)
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getDigit6 (int& result)
|
||||
{
|
||||
std::string::size_type i = _cursor;
|
||||
if (i < _length &&
|
||||
_length - i >= 6)
|
||||
{
|
||||
if (isdigit (_input[i + 0]) &&
|
||||
isdigit (_input[i + 1]) &&
|
||||
isdigit (_input[i + 2]) &&
|
||||
isdigit (_input[i + 3]) &&
|
||||
isdigit (_input[i + 4]) &&
|
||||
isdigit (_input[i + 5]))
|
||||
{
|
||||
result = strtoimax (_input.substr (_cursor, 6).c_str (), NULL, 10);
|
||||
_cursor += 6;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getDigit4 (int& result)
|
||||
{
|
||||
std::string::size_type i = _cursor;
|
||||
if (i < _length &&
|
||||
_length - i >= 4)
|
||||
{
|
||||
if (isdigit (_input[i + 0]) &&
|
||||
isdigit (_input[i + 1]) &&
|
||||
isdigit (_input[i + 2]) &&
|
||||
isdigit (_input[i + 3]))
|
||||
{
|
||||
result = strtoimax (_input.substr (_cursor, 4).c_str (), NULL, 10);
|
||||
_cursor += 4;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getDigit2 (int& result)
|
||||
{
|
||||
std::string::size_type i = _cursor;
|
||||
if (i < _length &&
|
||||
_length - i >= 2)
|
||||
{
|
||||
if (isdigit (_input[i + 0]) &&
|
||||
isdigit (_input[i + 1]))
|
||||
{
|
||||
result = strtoimax (_input.substr (_cursor, 2).c_str (), NULL, 10);
|
||||
_cursor += 2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Nibbler::getInt (int& result)
|
||||
{
|
||||
@@ -716,7 +779,6 @@ bool Nibbler::getDateISO (time_t& t)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef NIBBLER_FEATURE_DATE
|
||||
// Parse the longest integer using the next 'limit' characters of 'result'
|
||||
// following position 'i' (when strict is true, the number of digits must be
|
||||
// equal to limit).
|
||||
@@ -758,6 +820,7 @@ bool Nibbler::parseDigits(std::string::size_type& i,
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef NIBBLER_FEATURE_DATE
|
||||
bool Nibbler::getDate (const std::string& format, time_t& t)
|
||||
{
|
||||
std::string::size_type i = _cursor;
|
||||
|
||||
Reference in New Issue
Block a user