mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 05:06:24 +00:00
feat(Core/Common): delete old Tokenizer (#10121)
This commit is contained in:
@@ -31,44 +31,6 @@
|
||||
#include <string>
|
||||
#include <utf8.h>
|
||||
|
||||
Tokenizer::Tokenizer(const std::string& src, const char sep, uint32 vectorReserve)
|
||||
{
|
||||
m_str = new char[src.length() + 1];
|
||||
memcpy(m_str, src.c_str(), src.length() + 1);
|
||||
|
||||
if (vectorReserve)
|
||||
{
|
||||
m_storage.reserve(vectorReserve);
|
||||
}
|
||||
|
||||
char* posold = m_str;
|
||||
char* posnew = m_str;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (*posnew == sep)
|
||||
{
|
||||
m_storage.push_back(posold);
|
||||
posold = posnew + 1;
|
||||
|
||||
*posnew = '\0';
|
||||
}
|
||||
else if (*posnew == '\0')
|
||||
{
|
||||
// Hack like, but the old code accepted these kind of broken strings,
|
||||
// so changing it would break other things
|
||||
if (posold != posnew)
|
||||
{
|
||||
m_storage.push_back(posold);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
++posnew;
|
||||
}
|
||||
}
|
||||
|
||||
void stripLineInvisibleChars(std::string& str)
|
||||
{
|
||||
static std::string const invChars = " \t\7\n";
|
||||
|
||||
@@ -40,34 +40,6 @@ template<typename T, class S> struct Finder
|
||||
bool operator()(const std::pair<int, S>& obj) { return obj.second.*idMember_ == val_; }
|
||||
};
|
||||
|
||||
class Tokenizer
|
||||
{
|
||||
public:
|
||||
typedef std::vector<char const*> StorageType;
|
||||
|
||||
typedef StorageType::size_type size_type;
|
||||
|
||||
typedef StorageType::const_iterator const_iterator;
|
||||
typedef StorageType::reference reference;
|
||||
typedef StorageType::const_reference const_reference;
|
||||
|
||||
public:
|
||||
Tokenizer(const std::string& src, char const sep, uint32 vectorReserve = 0);
|
||||
~Tokenizer() { delete[] m_str; }
|
||||
|
||||
[[nodiscard]] const_iterator begin() const { return m_storage.begin(); }
|
||||
[[nodiscard]] const_iterator end() const { return m_storage.end(); }
|
||||
|
||||
[[nodiscard]] size_type size() const { return m_storage.size(); }
|
||||
|
||||
reference operator [] (size_type i) { return m_storage[i]; }
|
||||
const_reference operator [] (size_type i) const { return m_storage[i]; }
|
||||
|
||||
private:
|
||||
char* m_str;
|
||||
StorageType m_storage;
|
||||
};
|
||||
|
||||
void stripLineInvisibleChars(std::string& src);
|
||||
|
||||
AC_COMMON_API Optional<int32> MoneyStringToMoney(std::string_view moneyString);
|
||||
|
||||
Reference in New Issue
Block a user