summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/libutil.h
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-24 12:42:08 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-24 12:42:08 +0000
commitc19b2fdd21ba70ded0b4f42a8c7d018108d2d70d (patch)
tree4b4c96386291048dbb254a73cf7a5d80c604b0e7 /crawl-ref/source/libutil.h
parent873dd0bfae9f9f78b3e978edb574e4793af7b03f (diff)
downloadcrawl-ref-c19b2fdd21ba70ded0b4f42a8c7d018108d2d70d.tar.gz
crawl-ref-c19b2fdd21ba70ded0b4f42a8c7d018108d2d70d.zip
[1818799] Reduce message spam from Olgreb's toxic radiance.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2535 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/libutil.h')
-rw-r--r--crawl-ref/source/libutil.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/crawl-ref/source/libutil.h b/crawl-ref/source/libutil.h
index 751baef885..42102991a4 100644
--- a/crawl-ref/source/libutil.h
+++ b/crawl-ref/source/libutil.h
@@ -19,9 +19,37 @@
#include <cctype>
#include <string>
#include <vector>
+#include <map>
+
+// A collection of named things that can be stacked. The collection merges
+// things that should be merged (by name) and outputs a comma-separated list
+// with the preferred description type.
+class named_thing_collection
+{
+public:
+ named_thing_collection();
+ void add_thing(const std::string &name);
+ std::string describe(description_level_type desc,
+ const char **plural_qualifiers = NULL,
+ const char **no_qualifier_suffix = NULL) const;
+ size_t size() const;
+ bool empty() const;
+private:
+ typedef std::map<std::string, int> name_count_map;
+ name_count_map names;
+ size_t nnames;
+};
extern const char *standard_plural_qualifiers[];
+// Applies a description type to a name, but does not pluralise! You
+// must pluralise the name if needed. The quantity is used to prefix the
+// name with a quantity if appropriate.
+std::string apply_description(description_level_type desc,
+ const std::string &name,
+ int quantity = 1,
+ bool num_in_words = false);
+
description_level_type description_type_by_name(const char *desc);
std::string lowercase_string(std::string s);
@@ -42,6 +70,7 @@ std::string pluralise(
const char *no_of[] = NULL);
std::string number_in_words(unsigned number, int pow = 0);
+std::string number_to_string(unsigned number, bool in_words = false);
bool shell_safe(const char *file);