Merge branch 'develop' into feature/develop-atys
commit
109ed7eba5
@ -0,0 +1,83 @@
|
||||
// NeL - MMORPG Framework <https://wiki.ryzom.dev/>
|
||||
// Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef NLMISC_DEEP_PTR_H
|
||||
#define NLMISC_DEEP_PTR_H
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
|
||||
namespace NLMISC {
|
||||
|
||||
/// Pointer template with deep copy and move semantics
|
||||
template<class T>
|
||||
class CDeepPtr
|
||||
{
|
||||
public:
|
||||
NL_FORCE_INLINE CDeepPtr() : m(NULL) { } //< Null
|
||||
NL_FORCE_INLINE ~CDeepPtr() { delete m; }
|
||||
|
||||
NL_FORCE_INLINE CDeepPtr(const CDeepPtr &p) : m(p.m ? new T(*p) : NULL) { } //< Copy operator
|
||||
NL_FORCE_INLINE CDeepPtr &operator=(const CDeepPtr &p) { if (p.m) { if (!m) m = new T(*p); else *m = *p; } else { delete m; m = NULL; } return *this; } //< Copy operator
|
||||
|
||||
#ifdef NL_CPP14
|
||||
NL_FORCE_INLINE CDeepPtr(CDeepPtr &&p) noexcept : m(p.m) { p.m = NULL; } //< Move operator
|
||||
NL_FORCE_INLINE CDeepPtr &operator=(CDeepPtr &&p) noexcept { delete m; m = p.m; p.m = NULL; return *this; } //< Move operator
|
||||
#endif
|
||||
|
||||
NL_FORCE_INLINE CDeepPtr(T *p) : m(p) { } //< Initializer
|
||||
NL_FORCE_INLINE CDeepPtr &operator=(T *p) { delete m; m = p; return *this; } //< Initializer
|
||||
|
||||
NL_FORCE_INLINE bool operator==(const CDeepPtr &p) const { return /* (m == p.m) || */ (m && p.m && *m == *p); }
|
||||
NL_FORCE_INLINE bool operator!=(const CDeepPtr &p) const { return !(*this == p); }
|
||||
|
||||
NL_FORCE_INLINE bool operator==(const T *p) const { return (m == p) || (m && p && *m == *p); }
|
||||
NL_FORCE_INLINE bool operator!=(const T *p) const { return !(*this == p); }
|
||||
|
||||
NL_FORCE_INLINE bool operator==(const T &p) const { return (m == &p) || (m && *m == p); }
|
||||
NL_FORCE_INLINE bool operator!=(const T &p) const { return !(*this == p); }
|
||||
|
||||
NL_FORCE_INLINE bool operator==(long int p) const { return (*this == (const T *)(ptrdiff_t)p); } //< == NULL
|
||||
NL_FORCE_INLINE bool operator!=(long int p) const { return (*this != (const T *)(ptrdiff_t)p); } //< != NULL
|
||||
|
||||
NL_FORCE_INLINE bool operator==(int p) const { return (*this == (const T *)(ptrdiff_t)p); } //< == 0
|
||||
NL_FORCE_INLINE bool operator!=(int p) const { return (*this != (const T *)(ptrdiff_t)p); } //< != 0
|
||||
|
||||
#ifdef NL_CPP14
|
||||
NL_FORCE_INLINE bool operator==(nullptr_t p) const { return (*this == (const T *)(ptrdiff_t)p); } //< == nullptr
|
||||
NL_FORCE_INLINE bool operator!=(nullptr_t p) const { return (*this != (const T *)(ptrdiff_t)p); } //< != nullptr
|
||||
#endif
|
||||
|
||||
NL_FORCE_INLINE T &operator*() { return *m; }
|
||||
NL_FORCE_INLINE const T &operator*() const { return *m; }
|
||||
NL_FORCE_INLINE T *operator->() { return m; }
|
||||
NL_FORCE_INLINE const T *operator->() const { return m; }
|
||||
|
||||
NL_FORCE_INLINE operator bool() const { return m; }
|
||||
NL_FORCE_INLINE bool operator!() const { return !m; }
|
||||
|
||||
NL_FORCE_INLINE T *ptr() { return m; }
|
||||
NL_FORCE_INLINE const T *ptr() const { return m; }
|
||||
|
||||
private:
|
||||
T *m;
|
||||
|
||||
};
|
||||
|
||||
} /* namespace NLMISC */
|
||||
|
||||
#endif /* #ifndef NLMISC_DEEP_PTR_H */
|
||||
|
||||
/* end of file */
|
@ -0,0 +1,131 @@
|
||||
// NeL - MMORPG Framework <https://wiki.ryzom.dev/>
|
||||
// Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef NLMISC_STRING_VIEW_H
|
||||
#define NLMISC_STRING_VIEW_H
|
||||
|
||||
#include <nel/misc/types_nl.h>
|
||||
#include <string>
|
||||
|
||||
#ifdef NL_CPP14
|
||||
using namespace std::string_literals;
|
||||
#ifdef NL_CPP17
|
||||
#include <string_view>
|
||||
using namespace std::string_view_literals;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NL_CPP14
|
||||
/// Obtain an std::string from a string literal.
|
||||
#define nlstr(strLit) (strLit##s)
|
||||
#else
|
||||
/// Obtain an std::string from a string literal.
|
||||
#define nlstr(strLit) (std::string(strLit))
|
||||
#endif
|
||||
|
||||
#ifdef NL_CPP17
|
||||
/// Obtain a string view from a string literal.
|
||||
#define nlsv(strLit) (strLit##sv)
|
||||
/// Obtain an std::string from a string view.
|
||||
#define nlsvs(strView) (std::string(strView))
|
||||
#else
|
||||
/// Obtain a string view from a string literal.
|
||||
#define nlsv(strLit) (CStringView(strLit, ::strlen(strLit)))
|
||||
/// Obtain an std::string from a string view.
|
||||
#define nlsvs(strView) (std::string(strView.data(), strView.size()))
|
||||
#endif
|
||||
|
||||
/// Obtain a temporary C-string from a string view. Use directly in argument, do not store.
|
||||
#define nlsvc(strView) ((strView.data()[strView.size()]) ? nlsvs(strView).c_str() : strView.data())
|
||||
|
||||
namespace NLMISC {
|
||||
|
||||
/// String view literals allow bypassing allocation and strlen calls.
|
||||
/// CStringView is a 100% drop-in replacement for (const char *str, size_t len) tuples. It's a non-owning reference.
|
||||
/// Always use `CStringView` where previously `const std::string &` would have been used. It avoids accidental copy.
|
||||
/// Gotcha: CStringView doesn't need to end with \0, so there's no guarantee with functions that expect \0 terminated strings,
|
||||
/// use the `nlsvc` macro to get a temporary C-string from a CStringView.
|
||||
/// Use the `nlsv` macro to get a CStringView from a string literal.
|
||||
/// Use the `nlstr` macro to get an std::string from a string literal.
|
||||
/// Use the `nlsvs` macro to get an std::string from a CStringView.
|
||||
#ifdef NL_CPP17
|
||||
typedef std::string_view CStringView;
|
||||
#else
|
||||
class CStringView
|
||||
{
|
||||
public:
|
||||
CStringView(const std::string &str) : m_Str(&str[0]), m_Len(str.size()) {}
|
||||
CStringView(const char *const str, const size_t len) : m_Str(str), m_Len(len) {}
|
||||
CStringView(const char *const str) : m_Str(str), m_Len(sizeof(str)) {}
|
||||
|
||||
inline const char *data() const { return m_Str; }
|
||||
inline size_t length() const { return m_Len; }
|
||||
inline size_t size() const { return m_Len; }
|
||||
|
||||
inline CStringView substr(const size_t offset, const size_t count = -1) { return CStringView(m_Str + offset, std::min(m_Len - offset, count)); }
|
||||
|
||||
inline bool operator==(const CStringView o) { if (m_Len != o.m_Len) return false; return memcmp(m_Str, o.m_Str, m_Len) == 0; }
|
||||
inline bool operator!=(const CStringView o) { if (m_Len != o.m_Len) return true; return memcmp(m_Str, o.m_Str, m_Len) != 0; }
|
||||
|
||||
struct const_iterator
|
||||
{
|
||||
public:
|
||||
const_iterator() : m_Addr(NULL) { }
|
||||
|
||||
inline void operator++()
|
||||
{
|
||||
++m_Addr;
|
||||
}
|
||||
inline void operator+=(ptrdiff_t v)
|
||||
{
|
||||
m_Addr += v;
|
||||
}
|
||||
inline void operator--()
|
||||
{
|
||||
--m_Addr;
|
||||
}
|
||||
inline void operator-=(ptrdiff_t v)
|
||||
{
|
||||
m_Addr -= v;
|
||||
}
|
||||
inline bool operator!=(const const_iterator &o) const { return m_Addr != o.m_Addr; }
|
||||
inline bool operator==(const const_iterator &o) const { return m_Addr == o.m_Addr; }
|
||||
inline const char &operator*() const { return *m_Addr; }
|
||||
|
||||
private:
|
||||
friend class CStringView;
|
||||
inline const_iterator(const char *addr) : m_Addr(addr) {}
|
||||
const char *m_Addr;
|
||||
|
||||
};
|
||||
|
||||
typedef const_iterator iterator;
|
||||
|
||||
iterator begin() const { return iterator(m_Str); }
|
||||
inline iterator end() const { return iterator(m_Str + m_Len); }
|
||||
|
||||
private:
|
||||
const char *m_Str;
|
||||
size_t m_Len;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif /* #ifndef NLMISC_STRING_VIEW_H */
|
||||
|
||||
/* end of file */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,31 @@
|
||||
// NeL - MMORPG Framework <https://wiki.ryzom.dev/>
|
||||
// Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "stdmisc.h"
|
||||
#include "nel/misc/string_view.h"
|
||||
|
||||
// STL includes
|
||||
|
||||
// Project includes
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
|
||||
void nothing_here_string_view_nl() { }
|
||||
|
||||
} /* namespace NLMISC */
|
||||
|
||||
/* end of file */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,11 @@
|
||||
FILE(GLOB SRC *.cpp *.h *.rc *.rc2)
|
||||
|
||||
SOURCE_GROUP("" FILES ${SRC})
|
||||
|
||||
ADD_EXECUTABLE(nl_utf_generator ${SRC})
|
||||
|
||||
TARGET_LINK_LIBRARIES(nl_utf_generator nelmisc)
|
||||
NL_DEFAULT_PROPS(nl_utf_generator "NeL, Tools, Misc: UTF Generator")
|
||||
NL_ADD_RUNTIME_FLAGS(nl_utf_generator)
|
||||
|
||||
INSTALL(TARGETS nl_utf_generator RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT toolsmisc)
|
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
@ -0,0 +1,425 @@
|
||||
// NeL - MMORPG Framework <https://wiki.ryzom.dev/>
|
||||
// Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/common.h"
|
||||
#include "nel/misc/string_common.h"
|
||||
#include "nel/misc/string_view.h"
|
||||
#include "nel/misc/utf_string_view.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
void printStringMap(const std::string &name, std::map<char, std::string> &m, bool trim)
|
||||
{
|
||||
std::cout << "static const char " << name << "[" << std::dec << (trim ? "64" : "256") << " * 4] = {\n";
|
||||
bool zero = false;
|
||||
for (int i = 0; i < (trim ? 64 : 256); ++i)
|
||||
{
|
||||
int x = trim ? i + 0x80 : i;
|
||||
if (m.find(x) == m.end())
|
||||
{
|
||||
if (x % 8 == 7)
|
||||
{
|
||||
zero = false;
|
||||
std::cout << "0, 0, 0, 0,\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
zero = true;
|
||||
std::cout << "0, 0, 0, 0, ";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (zero) std::cout << "\n";
|
||||
std::stringstream ss;
|
||||
ss << "'\\x" << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (m[x].length() > 0 ? (unsigned char)m[x][0] : 0)
|
||||
<< "', '\\x" << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (m[x].length() > 1 ? (unsigned char)m[x][1] : 0)
|
||||
<< "', '\\x" << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (m[x].length() > 2 ? (unsigned char)m[x][2] : 0)
|
||||
<< "', 0,\n";
|
||||
std::cout << ss.str();
|
||||
zero = false;
|
||||
}
|
||||
}
|
||||
if (zero) std::cout << "\n";
|
||||
std::cout << "};\n\n";
|
||||
}
|
||||
|
||||
void printMapMap(const std::string &name, const std::string &strName, std::map<char, std::map<char, std::string>> &m, int base, int size)
|
||||
{
|
||||
std::cout << "static const char *" << name << "[" << size << "] = {\n";
|
||||
bool zero = false;
|
||||
for (int i = base; i < (base + size); ++i)
|
||||
{
|
||||
int x = i;
|
||||
if (m.find(x) == m.end())
|
||||
{
|
||||
if (x % 32 == 1315)
|
||||
{
|
||||
zero = false;
|
||||
std::cout << "0, \n";
|
||||
}
|
||||
else
|
||||
{
|
||||
zero = true;
|
||||
std::cout << "0, ";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (zero) std::cout << "\n";
|
||||
std::stringstream n;
|
||||
n << strName;
|
||||
n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)x;
|
||||
std::cout << n.str() << ",\n";
|
||||
zero = false;
|
||||
}
|
||||
}
|
||||
if (zero) std::cout << "\n";
|
||||
std::cout << std::dec << "};\n\n";
|
||||
}
|
||||
|
||||
void printMapMapMap(const std::string &name, const std::string &mapName, std::map<char, std::map<char, std::map<char, std::string>>> &m, int base, int size)
|
||||
{
|
||||
std::cout << "static const char **" << name << "[" << size << "] = {\n";
|
||||
bool zero = false;
|
||||
for (int i = base; i < (base + size); ++i)
|
||||
{
|
||||
int x = i;
|
||||
if (m.find(x) == m.end())
|
||||
{
|
||||
if (x % 32 == 1315)
|
||||
{
|
||||
zero = false;
|
||||
std::cout << "0, \n";
|
||||
}
|
||||
else
|
||||
{
|
||||
zero = true;
|
||||
std::cout << "0, ";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (zero) std::cout << "\n";
|
||||
std::stringstream n;
|
||||
n << mapName;
|
||||
n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)x;
|
||||
std::cout << n.str() << ",\n";
|
||||
zero = false;
|
||||
}
|
||||
}
|
||||
if (zero) std::cout << "\n";
|
||||
std::cout << "};\n\n";
|
||||
}
|
||||
|
||||
void printMapMapMapMap(const std::string &name, const std::string &mapName, std::map<char, std::map<char, std::map<char, std::map<char, std::string>>>> &m, int base, int size)
|
||||
{
|
||||
std::cout << "static const char ***" << name << "[" << size << "] = {\n";
|
||||
bool zero = false;
|
||||
for (int i = base; i < (base + size); ++i)
|
||||
{
|
||||
int x = i;
|
||||
if (m.find(x) == m.end())
|
||||
{
|
||||
if (x % 32 == 1315)
|
||||
{
|
||||
zero = false;
|
||||
std::cout << "0, \n";
|
||||
}
|
||||
else
|
||||
{
|
||||
zero = true;
|
||||
std::cout << "0, ";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (zero) std::cout << "\n";
|
||||
std::stringstream n;
|
||||
n << mapName;
|
||||
n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)x;
|
||||
std::cout << n.str() << ",\n";
|
||||
zero = false;
|
||||
}
|
||||
}
|
||||
if (zero) std::cout << "\n";
|
||||
std::cout << "};\n\n";
|
||||
}
|
||||
|
||||
void generateMap(const std::string &file, const std::string &name, const std::vector<u32char> &map)
|
||||
{
|
||||
std::map<char, std::string> m1;
|
||||
std::map<char, std::map<char, std::string>> m2;
|
||||
std::map<char, std::map<char, std::map<char, std::string>>> m3;
|
||||
std::map<char, std::map<char, std::map<char, std::map<char, std::string>>>> m4;
|
||||
for (u32char i = 0; i < 0x110000; ++i)
|
||||
{
|
||||
if (map[i] != i)
|
||||
{
|
||||
std::string from;
|
||||
NLMISC::CUtfStringView::append(from, i);
|
||||
std::string to;
|
||||
NLMISC::CUtfStringView::append(to, map[i]);
|
||||
// assert(from.size() == to.size());
|
||||
if (from.length() == 1)
|
||||
{
|
||||
m1[from[0]] = to;
|
||||
}
|
||||
else if (from.length() == 2)
|
||||
{
|
||||
if (m2.find(from[0]) == m2.end())
|
||||
m2[from[0]] = std::map<char, std::string>();
|
||||
m2[from[0]][from[1]] = to;
|
||||
}
|
||||
else if (from.length() == 3)
|
||||
{
|
||||
if (m3.find(from[0]) == m3.end())
|
||||
m3[from[0]] = std::map<char, std::map<char, std::string>>();
|
||||
if (m3[from[0]].find(from[1]) == m3[from[0]].end())
|
||||
m3[from[0]][from[1]] = std::map<char, std::string>();
|
||||
m3[from[0]][from[1]][from[2]] = to;
|
||||
}
|
||||
else if (from.length() == 4)
|
||||
{
|
||||
if (m4.find(from[0]) == m4.end())
|
||||
m4[from[0]] = std::map<char, std::map<char, std::map<char, std::string>>>();
|
||||
if (m4[from[0]].find(from[1]) == m4[from[0]].end())
|
||||
m4[from[0]][from[1]] = std::map<char, std::map<char, std::string>>();
|
||||
if (m4[from[0]][from[1]].find(from[2]) == m4[from[0]][from[1]].end())
|
||||
m4[from[0]][from[1]][from[2]] = std::map<char, std::string>();
|
||||
m4[from[0]][from[1]][from[2]][from[3]] = to;
|
||||
}
|
||||
}
|
||||
}
|
||||
printStringMap("s_" + name, m1, false);
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
std::stringstream n;
|
||||
n << "s_" << name;
|
||||
if (m2.find(i) != m2.end())
|
||||
{
|
||||
n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i;
|
||||
printStringMap(n.str(), m2[i], true);
|
||||
}
|
||||
else if (m3.find(i) != m3.end())
|
||||
{
|
||||
n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i;
|
||||
for (int j = 0; j < 256; ++j)
|
||||
{
|
||||
if (m3[i].find(j) != m3[i].end())
|
||||
{
|
||||
std::stringstream nn;
|
||||
nn << n.str();
|
||||
nn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)j;
|
||||
printStringMap(nn.str(), m3[i][j], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m4.find(i) != m4.end())
|
||||
{
|
||||
n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i;
|
||||
for (int j = 0; j < 256; ++j)
|
||||
{
|
||||
if (m4[i].find(j) != m4[i].end())
|
||||
{
|
||||
std::stringstream nn;
|
||||
nn << n.str();
|
||||
nn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)j;
|
||||
for (int k = 0; k < 256; ++k)
|
||||
{
|
||||
if (m4[i][j].find(k) != m4[i][j].end())
|
||||
{
|
||||
std::stringstream nnn;
|
||||
nnn << nn.str();
|
||||
nnn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)k;
|
||||
printStringMap(nnn.str(), m4[i][j][k], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
printMapMap("s_" + name + "Map", "s_" + name, m2, 0xC0, 32);
|
||||
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
std::stringstream n;
|
||||
n << "s_" << name << "Map";
|
||||
std::stringstream nn;
|
||||
nn << "s_" << name;
|
||||
if (m3.find(i) != m3.end())
|
||||
{
|
||||
n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i;
|
||||
nn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i;
|
||||
printMapMap(n.str(), nn.str(), m3[i], 0x80, 64);
|
||||
}
|
||||
}
|
||||
printMapMapMap("s_" + name + "MapMap", "s_" + name + "Map", m3, 0xE0, 16);
|
||||
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
std::stringstream n;
|
||||
n << "s_" << name << "Map";
|
||||
std::stringstream nn;
|
||||
nn << "s_" << name;
|
||||
std::stringstream nnn;
|
||||
nnn << "s_" << name << "MapMap";
|
||||
if (m4.find(i) != m4.end())
|
||||
{
|
||||
n << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i;
|
||||
nn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i;
|
||||
nnn << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)i;
|
||||
for (int j = 0; j < 256; ++j)
|
||||
{
|
||||
if (m4[i].find(j) != m4[i].end())
|
||||
{
|
||||
std::stringstream n2, nn2;
|
||||
n2 << n.str() << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)j;
|
||||
nn2 << nn.str() << std::hex << std::setw(2) << std::setfill('0') << std::uppercase << (unsigned int)j;
|
||||
printMapMap(n2.str(), nn2.str(), m4[i][j], 0x80, 64);
|
||||
}
|
||||
}
|
||||
printMapMapMap(nnn.str(), n.str(), m4[i], 0x80, 64);
|
||||
}
|
||||
}
|
||||
printMapMapMapMap("s_" + name + "MapMapMap", "s_" + name + "MapMap", m4, 0xF0, 8);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
std::ifstream fi("UnicodeData.txt");
|
||||
|
||||
std::vector<u32char> upper;
|
||||
std::vector<u32char> lower;
|
||||
std::vector<u32char> title;
|
||||
std::vector<u32char> ci;
|
||||
|
||||
upper.resize(0x110000);
|
||||
lower.resize(0x110000);
|
||||
title.resize(0x110000);
|
||||
ci.resize(0x110000);
|
||||
|
||||
for (u32char i = 0; i < 0x110000; ++i)
|
||||
{
|
||||
upper[i] = i;
|
||||
lower[i] = i;
|
||||
title[i] = i;
|
||||
ci[i] = i;
|
||||
}
|
||||
|
||||
std::string line;
|
||||
while (std::getline(fi, line))
|
||||
{
|
||||
std::vector<std::string> cols;
|
||||
NLMISC::explode(line, nlstr(";"), cols, false);
|
||||
nlassert(cols.size() == 15);
|
||||
|
||||
u32char c = NLMISC::atoiInt64(cols[0].c_str(), 16);
|
||||
u32char up = NLMISC::atoiInt64(cols[12].c_str(), 16);
|
||||
u32char low = NLMISC::atoiInt64(cols[13].c_str(), 16);
|
||||
u32char tit = NLMISC::atoiInt64(cols[14].c_str(), 16);
|
||||
|
||||
if (up) upper[c] = up;
|
||||
if (low) lower[c] = low;
|
||||
if (tit) title[c] = tit;
|
||||
}
|
||||
|
||||
std::vector<u32char> ref;
|
||||
int rounds = 0;
|
||||
for (;;)
|
||||
{
|
||||
ref = ci;
|
||||
|
||||
for (u32char i = 0; i < 0x110000; ++i)
|
||||
{
|
||||
ci[i] = title[ci[i]];
|
||||
}
|
||||
|
||||
for (u32char i = 0; i < 0x110000; ++i)
|
||||
{
|
||||
ci[i] = upper[ci[i]];
|
||||
}
|
||||
|
||||
for (u32char i = 0; i < 0x110000; ++i)
|
||||
{
|
||||
ci[i] = lower[ci[i]];
|
||||
}
|
||||
|
||||
bool equal = true;
|
||||
for (u32char i = 0; i < 0x110000; ++i)
|
||||
{
|
||||
if (ci[i] != ref[i])
|
||||
equal = false;
|
||||
}
|
||||
++rounds;
|
||||
std::cout << rounds << std::endl;
|
||||
if (equal)
|
||||
break;
|
||||
}
|
||||
|
||||
for (u32char i = 0; i < 0x110000; ++i)
|
||||
{
|
||||
if (ci[i] != lower[i])
|
||||
std::cout << i << std::endl;
|
||||
}
|
||||
|
||||
generateMap("string_to_upper", "StringToUpper", upper);
|
||||
//generateMap("string_to_lower", "StringToLower", lower);
|
||||
//generateMap("string_to_title", "StringToTitle", title);
|
||||
//generateMap("string_to_ci", "StringToCaseInsensitive", ci);
|
||||
|
||||
std::string test = nlstr("Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν, ὦ ἄνδρες ᾿Αθηναῖοι,");
|
||||
std::string testUpper = NLMISC::toUpper(test);
|
||||
std::string testLower = NLMISC::toLower(test);
|
||||
std::string testUpper2 = NLMISC::toUpper(testLower);
|
||||
std::string testLower2 = NLMISC::toLower(testUpper);
|
||||
std::cout << test << std::endl;
|
||||
std::cout << testUpper << std::endl;
|
||||
std::cout << testLower << std::endl;
|
||||
std::cout << testUpper2 << std::endl;
|
||||
std::cout << testLower2 << std::endl;
|
||||
|
||||
int cci1 = NLMISC::compareCaseInsensitive("bAAAAfdsklj", "Cldsfjslkf");
|
||||
int cci2 = NLMISC::compareCaseInsensitive("Cldsfjslkf", "bAAAAfdsklj");
|
||||
int strc1 = strcmp(NLMISC::toLower("bAAAAfdsklj").c_str(), NLMISC::toLower("Cldsfjslkf").c_str());
|
||||
int strc2 = strcmp(NLMISC::toLower("Cldsfjslkf").c_str(), NLMISC::toLower("bAAAAfdsklj").c_str());
|
||||
|
||||
int bcci1 = NLMISC::compareCaseInsensitive("bAAAAfdsklj", "AnlsqFDS");
|
||||
int bcci2 = NLMISC::compareCaseInsensitive("AnlsqFDS", "bAAAAfdsklj");
|
||||
int bstrc1 = strcmp(NLMISC::toLower("bAAAAfdsklj").c_str(), NLMISC::toLower("AnlsqFDS").c_str());
|
||||
int bstrc2 = strcmp(NLMISC::toLower("AnlsqFDS").c_str(), NLMISC::toLower("bAAAAfdsklj").c_str());
|
||||
|
||||
std::vector<std::string> arr;
|
||||
arr.push_back("AnlsqFDS");
|
||||
arr.push_back("yozeRNZE");
|
||||
arr.push_back("yOzeihfn");
|
||||
arr.push_back("bAAAAfdsklj");
|
||||
arr.push_back("Cldsfjslkf");
|
||||
std::sort(arr.begin(), arr.end(), NLMISC::ltCaseInsensitive);
|
||||
for (int i = 0; i < arr.size(); ++i)
|
||||
std::cout << arr[i] << std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* end of file */
|
@ -0,0 +1,42 @@
|
||||
#include <windows.h>
|
||||
#include "config.h"
|
||||
|
||||
IDI_MAIN_ICON ICON DISCARDABLE "gold_pill.ico"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define NL_FILEEXT "_d"
|
||||
#else
|
||||
#define NL_FILEEXT ""
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION NL_VERSION_RC
|
||||
PRODUCTVERSION NL_VERSION_RC
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_APP
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", AUTHOR
|
||||
VALUE "FileDescription", "NeL UTF Generator"
|
||||
VALUE "FileVersion", NL_VERSION
|
||||
VALUE "LegalCopyright", COPYRIGHT
|
||||
VALUE "OriginalFilename", "nl_utf_generator" NL_FILEEXT ".exe"
|
||||
VALUE "ProductName", "NeL Tools"
|
||||
VALUE "ProductVersion", NL_PRODUCT_VERSION
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x9, 1200
|
||||
END
|
||||
END
|
Loading…
Reference in New Issue