X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=libs%2Funiquenames.h;h=8ab72f57a80a82c01a0b3178bb662da9198d27d9;hb=231225d6f97d0b926b2e896e5783cccfbc7c5619;hp=4c4a531f1c23d16befd599136e587a4ce7a49478;hpb=12b372f89ce109a4db9d510884fbe7d05af79870;p=xonotic%2Fnetradiant.git diff --git a/libs/uniquenames.h b/libs/uniquenames.h index 4c4a531f..8ab72f57 100644 --- a/libs/uniquenames.h +++ b/libs/uniquenames.h @@ -39,7 +39,7 @@ public: { return m_value; } - void write(char* buffer) + void write(char* buffer) const { sprintf(buffer, "%u", m_value); } @@ -130,15 +130,17 @@ inline name_t name_read(const char* name) end = p; } - return name_t(CopiedString(name, end), Postfix(end)); + return name_t(CopiedString(StringRange(name, end)), Postfix(end)); } class PostFixes { +public: typedef std::map postfixes_t; postfixes_t m_postfixes; +private: Postfix find_first_empty() const { Postfix postfix("1"); @@ -207,15 +209,33 @@ class UniqueNames public: name_t make_unique(const name_t& name) const { + char buf[80]; + name_t r("",""); + name_write(buf, name); + globalErrorStream() << "find unique name for " << buf << "\n"; + globalErrorStream() << "> currently registered names:\n"; + for(names_t::const_iterator i = m_names.begin(); i != m_names.end(); ++i) + { + globalErrorStream() << ">> " << i->first.c_str() << ": "; + for(PostFixes::postfixes_t::const_iterator j = i->second.m_postfixes.begin(); j != i->second.m_postfixes.end(); ++j) + { + j->first.write(buf); + globalErrorStream() << " '" << buf << "'"; + } + globalErrorStream() << "\n"; + } names_t::const_iterator i = m_names.find(name.first); if(i == m_names.end()) { - return name; + r = name; } else { - return name_t(name.first, (*i).second.make_unique(name.second)); + r = name_t(name.first, (*i).second.make_unique(name.second)); } + name_write(buf, r); + globalErrorStream() << "> unique name is " << buf << "\n"; + return r; } void insert(const name_t& name)