78std::string
plural(T n,
const std::string &plural_phrase,
const std::string &singular_phrase=
"") {
79 assert(!plural_phrase.empty());
80 std::string retval =
insertCommas(boost::lexical_cast<std::string>(n)) +
" ";
82 if (!singular_phrase.empty()) {
83 retval += singular_phrase;
84 }
else if (boost::ends_with(plural_phrase,
"vertices")) {
85 retval += boost::replace_tail_copy(plural_phrase, 8,
"vertex");
86 }
else if (boost::ends_with(plural_phrase,
"indices")) {
87 retval += boost::replace_tail_copy(plural_phrase, 7,
"index");
88 }
else if (boost::ends_with(plural_phrase,
"ies") && plural_phrase.size() > 3) {
90 retval += boost::replace_tail_copy(plural_phrase, 3,
"y");
91 }
else if (boost::ends_with(plural_phrase,
"sses") || boost::ends_with(plural_phrase,
"indexes")) {
93 retval += boost::erase_tail_copy(plural_phrase, 2);
94 }
else if (boost::ends_with(plural_phrase,
"s") && plural_phrase.size() > 1) {
96 retval += boost::erase_tail_copy(plural_phrase, 1);
99 retval += plural_phrase;
102 retval += plural_phrase;
ROSE_UTIL_API void add_to_reason_string(std::string &result, bool isset, bool do_pad, const std::string &abbr, const std::string &full)
Append an abbreviation or full name to a string.