Sha256: 283578ce5d0ce8f8159d9616da4e29031e25e8bdd4cbb5224a773f6d47c09785

Contents?: true

Size: 1.9 KB

Versions: 6

Compression:

Stored size: 1.9 KB

Contents

/**
 * @file
 * Declares utility functions for dealing with strings.
 */
#pragma once

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/compare.hpp>
#pragma GCC diagnostic pop
#include <functional>
#include <string>
#include <vector>

namespace leatherman { namespace util {

        /**
         * Case-insensitive string comparison.
         */
        struct ciless : std::binary_function<std::string, std::string, bool>
        {
            /**
             * Compares two strings for a "less than" relationship using a case-insensitive comparison.
             * @param s1 The first string to compare.
             * @param s2 The second string to compare.
             * @return Returns true if s1 is less than s2 or false if s1 is equal to or greater than s2.
             */
            bool operator() (const std::string &s1, const std::string &s2) const {
                return boost::lexicographical_compare(s1, s2, boost::is_iless());
            }
        };

        /**
         * @return Returns the "s" string in case of more than one thing,
         *      an empty string otherwise.
         */
        std::string plural(int num_of_things);

        /**
         * @return Returns the "s" string if vector contains more than one item,
         *      an empty string otherwise.
         */
        template<typename T>
        std::string plural(std::vector<T> const& things);

        /** @return Returns universally unique identifier string. */
        std::string get_UUID();

        /**
         * Reads each line from the given string.
         * @param s The string to read.
         * @param callback The callback function that is passed each line in the string.
         */
        void each_line(std::string const& s, std::function<bool(std::string&)> callback);

}}  // namespace leatherman::util

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/leatherman/util/inc/leatherman/util/strings.hpp
facter-3.12.1.cfacter.20181031 ext/facter/leatherman/util/inc/leatherman/util/strings.hpp
facter-3.12.1.cfacter.20181023 ext/facter/leatherman/util/inc/leatherman/util/strings.hpp
facter-3.12.0.cfacter.20181004 ext/facter/leatherman/util/inc/leatherman/util/strings.hpp
facter-3.12.0.cfacter.20181001 ext/facter/leatherman/util/inc/leatherman/util/strings.hpp
facter-3.12.0.cfacter.20180918 ext/facter/leatherman/util/inc/leatherman/util/strings.hpp