diff options
Diffstat (limited to 'crawl-ref/source/libutil.h')
-rw-r--r-- | crawl-ref/source/libutil.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/crawl-ref/source/libutil.h b/crawl-ref/source/libutil.h index e68863bd57..6ae7bedec4 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); |