mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-27 06:10:52 -04:00
not used anymore
This commit is contained in:
parent
c01bf51a75
commit
5ab0396692
@ -1,102 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2006 Tommi Maekitalo
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* is provided AS IS, WITHOUT ANY WARRANTY; without even the implied
|
|
||||||
* warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and
|
|
||||||
* NON-INFRINGEMENT. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ZIM_QUNICODE_H
|
|
||||||
#define ZIM_QUNICODE_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iosfwd>
|
|
||||||
|
|
||||||
namespace zim
|
|
||||||
{
|
|
||||||
class QUnicodeChar
|
|
||||||
{
|
|
||||||
unsigned value;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QUnicodeChar(char hi, char lo)
|
|
||||||
: value(static_cast<unsigned>(static_cast<unsigned char>(hi)) << 8
|
|
||||||
| static_cast<unsigned>(static_cast<unsigned char>(lo)))
|
|
||||||
{ }
|
|
||||||
QUnicodeChar(char ch)
|
|
||||||
: value(static_cast<unsigned char>(ch))
|
|
||||||
{ }
|
|
||||||
QUnicodeChar(unsigned ch = 0)
|
|
||||||
: value(ch)
|
|
||||||
{ }
|
|
||||||
unsigned getValue() const { return value; }
|
|
||||||
unsigned char getCollateValue() const;
|
|
||||||
|
|
||||||
bool operator< (const QUnicodeChar& v) const
|
|
||||||
{ return getCollateValue() != v.getCollateValue()
|
|
||||||
? getCollateValue() < v.getCollateValue()
|
|
||||||
: value < v.value; }
|
|
||||||
|
|
||||||
bool operator== (const QUnicodeChar& v) const
|
|
||||||
{ return value == v.value; }
|
|
||||||
};
|
|
||||||
|
|
||||||
std::istream& operator>> (std::istream& in, QUnicodeChar& qc);
|
|
||||||
|
|
||||||
class QUnicodeString
|
|
||||||
{
|
|
||||||
std::string value;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QUnicodeString() { }
|
|
||||||
explicit QUnicodeString(const std::string& v)
|
|
||||||
: value(v)
|
|
||||||
{ }
|
|
||||||
static QUnicodeString fromUtf8(const std::string& v);
|
|
||||||
static QUnicodeString fromIso8859_15(const std::string& v);
|
|
||||||
|
|
||||||
const std::string& getValue() const { return value; }
|
|
||||||
void clear() { value.clear(); }
|
|
||||||
|
|
||||||
unsigned size() const;
|
|
||||||
std::string getCollateString() const;
|
|
||||||
int compare(unsigned pos, unsigned n, const QUnicodeString& v) const;
|
|
||||||
int compareCollate(unsigned pos, unsigned n, const QUnicodeString& v) const;
|
|
||||||
int compare(const QUnicodeString& v) const
|
|
||||||
{ return compare(0, size(), v); }
|
|
||||||
int compareCollate(const QUnicodeString& v) const
|
|
||||||
{ return compareCollate(0, size(), v); }
|
|
||||||
|
|
||||||
bool operator< (const QUnicodeString& v) const
|
|
||||||
{ return compare(v) < 0; }
|
|
||||||
bool operator== (const QUnicodeString& v) const
|
|
||||||
{ return value == v.value; }
|
|
||||||
bool operator> (const QUnicodeString& v) const
|
|
||||||
{ return v < *this; }
|
|
||||||
bool operator!= (const QUnicodeString& v) const
|
|
||||||
{ return value != v.value; }
|
|
||||||
bool operator<= (const QUnicodeString& v) const
|
|
||||||
{ return !(*this > v); }
|
|
||||||
bool operator>= (const QUnicodeString& v) const
|
|
||||||
{ return !(*this < v); }
|
|
||||||
|
|
||||||
std::string toXML() const;
|
|
||||||
std::string toUtf8() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream& out, const QUnicodeString& str);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // ZIM_QUNICODE_H
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
|||||||
/* tnt/stringlessignorecase.h
|
|
||||||
* Copyright (C) 2003 Tommi Maekitalo
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2.1 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library 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
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef ZIM_STRINGLESSIGNORECASE_H
|
|
||||||
#define ZIM_STRINGLESSIGNORECASE_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <functional>
|
|
||||||
#include <cctype>
|
|
||||||
|
|
||||||
namespace zim
|
|
||||||
{
|
|
||||||
template <typename stringType = std::string>
|
|
||||||
class StringLessIgnoreCase : public std::binary_function<stringType, stringType, bool>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool operator()(const stringType& s1, const stringType& s2) const
|
|
||||||
{
|
|
||||||
typename stringType::const_iterator it1 = s1.begin();
|
|
||||||
typename stringType::const_iterator it2 = s2.begin();
|
|
||||||
while (it1 != s1.end() && it2 != s2.end())
|
|
||||||
{
|
|
||||||
if (*it1 != *it2)
|
|
||||||
{
|
|
||||||
char c1 = std::toupper(*it1);
|
|
||||||
char c2 = std::toupper(*it2);
|
|
||||||
if (c1 < c2)
|
|
||||||
return true;
|
|
||||||
else if (c2 < c1)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
++it1;
|
|
||||||
++it2;
|
|
||||||
}
|
|
||||||
return it1 == s1.end() ? (it2 != s2.end()) : (it2 == s2.end());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // ZIM_STRINGLESSIGNORECASE_H
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user