diff --git a/.codecov.yml b/.codecov.yml index 959972a..69cb760 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1 +1 @@ -comment: false \ No newline at end of file +comment: false diff --git a/ChangeLog b/ChangeLog index 191d001..17c1fb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,13 @@ +2016-12-06 Dirk Eddelbuettel + + * src/anytime.cpp (isAtLeastGivenLengthAndAllDigits): Simplified + using Boost classification and predicate use + 2016-12-05 Dirk Eddelbuettel * src/anytime.cpp (format): Condition only on Rcpp version - * tests/utilities.R: Call anytime:::format() + + * tests/utilities.R: Call anytime:::format() 2016-12-04 Dirk Eddelbuettel diff --git a/src/anytime.cpp b/src/anytime.cpp index 35b2675..49793db 100644 --- a/src/anytime.cpp +++ b/src/anytime.cpp @@ -24,10 +24,13 @@ #include #include #include +#include #include + #include namespace bt = boost::posix_time; +namespace ba = boost::algorithm; static bool debug = false; @@ -201,12 +204,7 @@ void stringSplitter(const std::string & in, const std::string spliton, // yes, we could use regular expression -- but then we'd either be C++11 or would // require an additional library with header / linking requirement (incl boost regex) bool isAtLeastGivenLengthAndAllDigits(const std::string& s, const unsigned int n) { - bool res = s.size() >= n; - size_t i = 0; - while (res && i < n) { - res = res && s[i] >= '0' && s[i] <= '9'; - i++; - } + bool res = (s.size() >= n) && ba::all(s, ba::is_digit()); if (debug) Rcpp::Rcout << "s: " << s << " len: " << s.size() << " res: " << res << std::endl; return res; } @@ -403,7 +401,7 @@ std::vector format(Rcpp::NumericVector x) { std::vector z(x.size()); for (int i=0; i= RcppDevVersion(0,12,8,1) +#if RCPP_DEV_VERSION >= RcppDevVersion(0,12,8,2) z[i] = d.format(); #else z[i] = "";