|
From: Christian P. <cp...@us...> - 2005-01-14 14:46:13
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19335/include/pclasses/Unicode Modified Files: Makefile.am Added Files: uctype.h ustring.h Log Message: Unicode re-work. Lets get compatible to std::basic_string<>. Unicode::Char, Unicode::String will be obsoleted. Index: Makefile.am =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.am 23 Dec 2004 04:32:17 -0000 1.1 +++ Makefile.am 14 Jan 2005 14:46:01 -0000 1.2 @@ -1,3 +1,3 @@ INCLUDES = METASOURCES = AUTO -pkginclude_HEADERS = Char.h String.h TextStream.h +pkginclude_HEADERS = uctype.h ustring.h Char.h String.h TextStream.h --- NEW FILE: ustring.h --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library 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 WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef P_Unicode_ustring_h #define P_Unicode_ustring_h #include <pclasses/Unicode/uctype.h> #include <string> namespace P { namespace Unicode { typedef off_t ustreampos; struct ustate_t { }; int umemcmp(const uchar_t* s1, const uchar_t* s2, size_t n); size_t ucslen(const uchar_t* s); const uchar_t* umemchr(const uchar_t* s, size_t n, uchar_t a); uchar_t* umemmove(uchar_t* s1, const uchar_t* s2, size_t n); uchar_t* umemcpy(uchar_t* s1, const uchar_t* s2, size_t n); uchar_t* umemset(uchar_t* s, size_t n, uchar_t a); } // !namespace Unicode } // !namespace P namespace std { template<> struct char_traits<P::Unicode::uchar_t> { typedef P::Unicode::uchar_t char_type; typedef P::uint32_t int_type; typedef streamoff off_type; typedef P::Unicode::ustreampos pos_type; typedef P::Unicode::ustate_t state_type; static void assign(char_type& c1, const char_type& c2) { c1 = c2; } static bool eq(const char_type& c1, const char_type& c2) { return c1 == c2; } static bool lt(const char_type& c1, const char_type& c2) { return P::Unicode::umemcmp(&c1, &c2, 1) < 0; } static int compare(const char_type* c1, const char_type* c2, size_t n) { return P::Unicode::umemcmp(c1, c2, n); } static size_t length(const char_type* s) { return P::Unicode::ucslen(s); } static const char_type* find(const char_type* s, size_t n, const char_type& a) { return P::Unicode::umemchr(s, a, n); } static char_type* move(char_type* s1, const char_type* s2, int_type n) { return P::Unicode::umemmove(s1, s2, n); } static char_type* copy(char_type* s1, const char_type* s2, size_t n) { return P::Unicode::umemcpy(s1, s2, n); } static char_type* assign(char_type* s, size_t n, char_type a) { return P::Unicode::umemset(s, a, n); } static char_type to_char_type(const int_type& c) { return char_type(c); } static int_type to_int_type(const char_type& c) { return int_type(c); } static bool eq_int_type(const int_type& c1, const int_type& c2) { return c1 == c2; } static int_type eof() { return static_cast<int_type>(UEOF); } static int_type not_eof(const int_type& c) { return eq_int_type(c, eof()) ? 0 : c; } }; } namespace P { namespace Unicode { typedef std::basic_string<uchar_t, std::char_traits<uchar_t>, std::allocator<uchar_t> > ustring; ustring str(const char* str); } // !namespace Unicode } // !namespace P #endif --- NEW FILE: uctype.h --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library 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 WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef P_Unicode_uctype_h #define P_Unicode_uctype_h #include <pclasses/BasicTypes.h> namespace P { namespace Unicode { typedef uint32_t uchar_t; int isualnum(uchar_t c); int isualpha(uchar_t c); int isucntrl(uchar_t c); int isudigit(uchar_t c); int isugraph(uchar_t c); int isulower(uchar_t c); int isuprint(uchar_t c); int isupunct(uchar_t c); int isuspace(uchar_t c); int isuupper(uchar_t c); uchar_t touchar(char c); uchar_t toulower(uchar_t c); uchar_t touupper(uchar_t c); #define UEOF ((P::Unicode::uchar_t)-1) } // !namespace Unicode } // !namespace P #endif |