From: Christian P. <cp...@us...> - 2005-01-24 01:20:20
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7811/Unicode Modified Files: ustring.h Log Message: File was encoded with win32 crlf - fixed. Added export-macro. Index: ustring.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/ustring.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ustring.h 14 Jan 2005 14:46:01 -0000 1.1 +++ ustring.h 24 Jan 2005 01:20:09 -0000 1.2 @@ -1,116 +1,117 @@ -/*************************************************************************** - * 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 +/*************************************************************************** + * 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/Export.h> +#include <pclasses/Unicode/uctype.h> +#include <string> + +namespace P { + +namespace Unicode { + +typedef off_t ustreampos; +struct ustate_t { }; + +PUNICODE_EXPORT int umemcmp(const uchar_t* s1, const uchar_t* s2, size_t n); +PUNICODE_EXPORT size_t ucslen(const uchar_t* s); +PUNICODE_EXPORT const uchar_t* umemchr(const uchar_t* s, size_t n, uchar_t a); +PUNICODE_EXPORT uchar_t* umemmove(uchar_t* s1, const uchar_t* s2, size_t n); +PUNICODE_EXPORT uchar_t* umemcpy(uchar_t* s1, const uchar_t* s2, size_t n); +PUNICODE_EXPORT 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; + +PUNICODE_EXPORT ustring str(const char* str); + +} // !namespace Unicode + +} // !namespace P + +#endif |