|
|
@ -35,95 +35,98 @@ typedef std::basic_string<ucchar> ucstringbase;
|
|
|
|
class ucstring : public ucstringbase
|
|
|
|
class ucstring : public ucstringbase
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
ucstring() { }
|
|
|
|
|
|
|
|
|
|
|
|
ucstring () {}
|
|
|
|
ucstring(const ucstringbase &str)
|
|
|
|
|
|
|
|
: ucstringbase(str)
|
|
|
|
ucstring (const ucstringbase &str) : ucstringbase (str) {}
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ucstring (const std::string &str) : ucstringbase ()
|
|
|
|
ucstring(const std::string &str)
|
|
|
|
|
|
|
|
: ucstringbase()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rawCopy(str);
|
|
|
|
rawCopy(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
~ucstring () {}
|
|
|
|
~ucstring() { }
|
|
|
|
|
|
|
|
|
|
|
|
ucstring &operator= (ucchar c)
|
|
|
|
ucstring &operator=(ucchar c)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
resize (1);
|
|
|
|
resize(1);
|
|
|
|
operator[](0) = c;
|
|
|
|
operator[](0) = c;
|
|
|
|
return *this;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ucstring &operator= (const char *str)
|
|
|
|
ucstring &operator=(const char *str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
resize (strlen (str));
|
|
|
|
resize(strlen(str));
|
|
|
|
for (uint i = 0; i < strlen (str); i++)
|
|
|
|
for (uint i = 0; i < strlen(str); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
operator[](i) = uint8(str[i]);
|
|
|
|
operator[](i) = uint8(str[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ucstring &operator= (const std::string &str)
|
|
|
|
ucstring &operator=(const std::string &str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
resize (str.size ());
|
|
|
|
resize(str.size());
|
|
|
|
for (uint i = 0; i < str.size (); i++)
|
|
|
|
for (uint i = 0; i < str.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
operator[](i) = uint8(str[i]);
|
|
|
|
operator[](i) = uint8(str[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ucstring &operator= (const ucstringbase &str)
|
|
|
|
ucstring &operator=(const ucstringbase &str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstringbase::operator =(str);
|
|
|
|
ucstringbase::operator=(str);
|
|
|
|
return *this;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ucstring& operator= (const ucchar *str)
|
|
|
|
ucstring &operator=(const ucchar *str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstringbase::operator =(str);
|
|
|
|
ucstringbase::operator=(str);
|
|
|
|
return *this;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ucstring &operator+= (ucchar c)
|
|
|
|
ucstring &operator+=(ucchar c)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
resize (size() + 1);
|
|
|
|
resize(size() + 1);
|
|
|
|
operator[](size()-1) = c;
|
|
|
|
operator[](size() - 1) = c;
|
|
|
|
return *this;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ucstring &operator+= (const char *str)
|
|
|
|
ucstring &operator+=(const char *str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t s = size();
|
|
|
|
size_t s = size();
|
|
|
|
resize (s + strlen(str));
|
|
|
|
resize(s + strlen(str));
|
|
|
|
for (uint i = 0; i < strlen(str); i++)
|
|
|
|
for (uint i = 0; i < strlen(str); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
operator[](s+i) = uint8(str[i]);
|
|
|
|
operator[](s + i) = uint8(str[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ucstring &operator+= (const std::string &str)
|
|
|
|
ucstring &operator+=(const std::string &str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t s = size();
|
|
|
|
size_t s = size();
|
|
|
|
resize (s + str.size());
|
|
|
|
resize(s + str.size());
|
|
|
|
for (uint i = 0; i < str.size(); i++)
|
|
|
|
for (uint i = 0; i < str.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
operator[](s+i) = uint8(str[i]);
|
|
|
|
operator[](s + i) = uint8(str[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ucstring &operator+= (const ucstringbase &str)
|
|
|
|
ucstring &operator+=(const ucstringbase &str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstringbase::operator +=(str);
|
|
|
|
ucstringbase::operator+=(str);
|
|
|
|
return *this;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ucchar *c_str() const
|
|
|
|
const ucchar *c_str() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ucchar *tmp = ucstringbase::c_str();
|
|
|
|
const ucchar *tmp = ucstringbase::c_str();
|
|
|
|
const_cast<ucchar*>(tmp)[size()] = 0;
|
|
|
|
const_cast<ucchar *>(tmp)[size()] = 0;
|
|
|
|
return tmp;
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -131,7 +134,7 @@ public:
|
|
|
|
void toString(std::string &str) const;
|
|
|
|
void toString(std::string &str) const;
|
|
|
|
|
|
|
|
|
|
|
|
/// Converts the controlled ucstring and returns the resulting string
|
|
|
|
/// Converts the controlled ucstring and returns the resulting string
|
|
|
|
std::string toString () const
|
|
|
|
std::string toString() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string str;
|
|
|
|
std::string str;
|
|
|
|
toString(str);
|
|
|
|
toString(str);
|
|
|
@ -165,37 +168,36 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
void rawCopy(const std::string &str);
|
|
|
|
void rawCopy(const std::string &str);
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
inline ucstring operator+(const ucstringbase &ucstr, ucchar c)
|
|
|
|
inline ucstring operator+(const ucstringbase &ucstr, ucchar c)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring ret;
|
|
|
|
ucstring ret;
|
|
|
|
ret= ucstr;
|
|
|
|
ret = ucstr;
|
|
|
|
ret+= c;
|
|
|
|
ret += c;
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline ucstring operator+(const ucstringbase &ucstr, const char *c)
|
|
|
|
inline ucstring operator+(const ucstringbase &ucstr, const char *c)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring ret;
|
|
|
|
ucstring ret;
|
|
|
|
ret= ucstr;
|
|
|
|
ret = ucstr;
|
|
|
|
ret+= c;
|
|
|
|
ret += c;
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline ucstring operator+(const ucstringbase &ucstr, const std::string &c)
|
|
|
|
inline ucstring operator+(const ucstringbase &ucstr, const std::string &c)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring ret;
|
|
|
|
ucstring ret;
|
|
|
|
ret= ucstr;
|
|
|
|
ret = ucstr;
|
|
|
|
ret+= c;
|
|
|
|
ret += c;
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline ucstring operator+(ucchar c, const ucstringbase &ucstr)
|
|
|
|
inline ucstring operator+(ucchar c, const ucstringbase &ucstr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring ret;
|
|
|
|
ucstring ret;
|
|
|
|
ret= c;
|
|
|
|
ret = c;
|
|
|
|
ret += ucstr;
|
|
|
|
ret += ucstr;
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -203,7 +205,7 @@ inline ucstring operator+(ucchar c, const ucstringbase &ucstr)
|
|
|
|
inline ucstring operator+(const char *c, const ucstringbase &ucstr)
|
|
|
|
inline ucstring operator+(const char *c, const ucstringbase &ucstr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring ret;
|
|
|
|
ucstring ret;
|
|
|
|
ret= c;
|
|
|
|
ret = c;
|
|
|
|
ret += ucstr;
|
|
|
|
ret += ucstr;
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -211,24 +213,27 @@ inline ucstring operator+(const char *c, const ucstringbase &ucstr)
|
|
|
|
inline ucstring operator+(const std::string &c, const ucstringbase &ucstr)
|
|
|
|
inline ucstring operator+(const std::string &c, const ucstringbase &ucstr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring ret;
|
|
|
|
ucstring ret;
|
|
|
|
ret= c;
|
|
|
|
ret = c;
|
|
|
|
ret += ucstr;
|
|
|
|
ret += ucstr;
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace NLMISC
|
|
|
|
namespace NLMISC {
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Traits for hash_map using CEntityId
|
|
|
|
// Traits for hash_map using CEntityId
|
|
|
|
struct CUCStringHashMapTraits
|
|
|
|
struct CUCStringHashMapTraits
|
|
|
|
{
|
|
|
|
{
|
|
|
|
enum { bucket_size = 4, min_buckets = 8 };
|
|
|
|
enum
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bucket_size = 4,
|
|
|
|
|
|
|
|
min_buckets = 8
|
|
|
|
|
|
|
|
};
|
|
|
|
CUCStringHashMapTraits() { }
|
|
|
|
CUCStringHashMapTraits() { }
|
|
|
|
size_t operator() (const ucstring &id ) const
|
|
|
|
size_t operator()(const ucstring &id) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return id.size();
|
|
|
|
return id.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool operator() (const ucstring &id1, const ucstring &id2) const
|
|
|
|
bool operator()(const ucstring &id1, const ucstring &id2) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return id1 < id2;
|
|
|
|
return id1 < id2;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -239,18 +244,18 @@ struct CUCStringHashMapTraits
|
|
|
|
* \param a string or a char to transform to lower case
|
|
|
|
* \param a string or a char to transform to lower case
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
ucstring toLower (const ucstring &str);
|
|
|
|
ucstring toLower(const ucstring &str);
|
|
|
|
void toLower (ucchar *str);
|
|
|
|
void toLower(ucchar *str);
|
|
|
|
ucchar toLower (ucchar c);
|
|
|
|
ucchar toLower(ucchar c);
|
|
|
|
|
|
|
|
|
|
|
|
/** Convert an unicode string in upper case.
|
|
|
|
/** Convert an unicode string in upper case.
|
|
|
|
* Characters with accent are converted in a uppercase character without accent
|
|
|
|
* Characters with accent are converted in a uppercase character without accent
|
|
|
|
* \param a string or a char to transform to upper case
|
|
|
|
* \param a string or a char to transform to upper case
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
ucstring toUpper (const ucstring &str);
|
|
|
|
ucstring toUpper(const ucstring &str);
|
|
|
|
void toUpper (ucchar *str);
|
|
|
|
void toUpper(ucchar *str);
|
|
|
|
ucchar toUpper (ucchar c);
|
|
|
|
ucchar toUpper(ucchar c);
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|