Sha256: c93b4dd91ed1e0fb046d601f6a30a76cd37c2cba596f55ca637d6a771d2aa168

Contents?: true

Size: 1.01 KB

Versions: 16

Compression:

Stored size: 1.01 KB

Contents

#include <leatherman/util/strings.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/uuid_generators.hpp>

#include <sstream>

using namespace std;

namespace leatherman { namespace util {

    string plural(int num_of_things) {
        return num_of_things == 1 ? "" : "s";
    }

    template<>
    string plural<string>(vector<string> const& things) {
        return plural(things.size());
    }

    string get_UUID() {
        static boost::uuids::random_generator gen;
        boost::uuids::uuid uuid = gen();
        return boost::uuids::to_string(uuid);
    }

    void each_line(string const& s, function<bool(string&)> callback) {
        string line;
        istringstream in(s);
        while (getline(in, line)) {
        // Handle Windows CR in the string.
            if (line.size() && line.back() == '\r') {
                line.pop_back();
            }
            if (!callback(line)) {
                break;
            }
        }
    }

}}  // namespace leatherman::util

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/leatherman/util/src/strings.cc
facter-3.12.1.cfacter.20181031 ext/facter/leatherman/util/src/strings.cc
facter-3.11.6.cfacter.20181031 ext/facter/leatherman/util/src/strings.cc
facter-3.12.1.cfacter.20181023 ext/facter/leatherman/util/src/strings.cc
facter-3.11.5.cfacter.20181022 ext/facter/leatherman/util/src/strings.cc
facter-3.12.0.cfacter.20181004 ext/facter/leatherman/util/src/strings.cc
facter-3.12.0.cfacter.20181001 ext/facter/leatherman/util/src/strings.cc
facter-3.12.0.cfacter.20180918 ext/facter/leatherman/util/src/strings.cc
facter-3.11.4.cfacter.20180821 ext/facter/leatherman/util/src/strings.cc
facter-3.11.3.cfacter.20180716 ext/facter/leatherman/util/src/strings.cc
facter-3.11.2.cfacter.20180612 ext/facter/leatherman/util/src/strings.cc
facter-3.9.6.cfacter.20180612 ext/facter/leatherman/util/src/strings.cc
facter-3.11.2.cfacter.20180606 ext/facter/leatherman/util/src/strings.cc
facter-3.9.6.cfacter.20180606 ext/facter/leatherman/util/src/strings.cc
facter-3.11.0.cfacter.20180319 ext/facter/leatherman/util/src/strings.cc
cfacter-3.11.0.rc.20180314 ext/facter/leatherman/util/src/strings.cc