/usr/include/leatherman/util/strings.hpp is in libleatherman-dev 1.4.0+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | /**
* @file
* Declares utility functions for dealing with strings.
*/
#pragma once
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/compare.hpp>
#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
|