From: Christian P. <cp...@us...> - 2005-05-20 14:11:41
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/Unicode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7319 Modified Files: Char.h String.h Log Message: - Dropping own Unicode implementation. We now use UCI Index: Char.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/Char.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Char.h 6 May 2005 15:32:11 -0000 1.5 +++ Char.h 20 May 2005 14:11:32 -0000 1.6 @@ -23,177 +23,74 @@ #include <pclasses/Export.h> #include <pclasses/BasicTypes.h> -#include <pclasses/Unicode/uctype.h> -#include <cwchar> +#include <pclasses/Exception.h> namespace P { namespace Unicode { +typedef uint16_t uchar16_t; +typedef int32_t uchar32_t; + +class InvalidCharError: public RuntimeError { + public: + InvalidCharError(const char* what, const SourceInfo& si) throw(); + ~InvalidCharError() throw(); +}; + //! UNICODE 4.0 compliant character class class PUNICODE_EXPORT Char { public: - //! General category - enum Category { - Mark_NonSpacing, // Mn - Mark_SpacingCombining, // Mc - Mark_Enclosing, // Me - - Number_DecimalDigit, // Nd - Number_Letter, // Nl - Number_Other, // No - - Separator_Space, // Zs - Separator_Line, // Zl - Separator_Paragraph, // Zp - - Other_Control, // Cc - Other_Format, // Cf - Other_Surrogate, // Cs - Other_PrivateUse, // Co - Other_NotAssigned, // Cn - - Letter_Uppercase, // Lu - Letter_Lowercase, // Ll - Letter_Titlecase, // Lt - Letter_Modifier, // Lm - Letter_Other, // Lo - - Punctuation_Connector, // Pc - Punctuation_Dash, // Pd - Punctuation_Open, // Ps - Punctuation_Close, // Pe - Punctuation_InitialQuote, // Pi - Punctuation_FinalQuote, // Pf - Punctuation_Other, // Po - - Symbol_Math, // Sm - Symbol_Currency, // Sc - Symbol_Modifier, // Sk - Symbol_Other // So - }; - - //! Bidirectional Class - enum BidiClass { - LeftToRight, // L - LeftToRightEmbedding, // LRE - LeftToRightOverride, // LRO - RightToLeft, // R - RightToLeftArabic, // AL - RightToLeftEmbedding, // RLE - RightToLeftOverride, // RLO - PopDirectionalFormat, // PDF - EuropeanNumber, // EN - EuropeanNumberSeparator, // ES - EuropeanNumberTerminator, // ET - ArabicNumber, // AN - CommonNumberSeparator, // CS - NonSpacingMark, // NSM - BoundaryNeutral, // BN - ParagraphSeparator, // B - SegmentSeparator, // S - Whitespace, // WS - OtherNeutrals // ON - }; + Char(uchar32_t ch = 0) throw(InvalidCharError); + Char(const Char& ch) throw(); - //! Character Decomposition Tag - enum Decomposition { - Decomp_None, - Decomp_Standard, - Decomp_Font, // <font> - Decomp_NoBreak, // <noBreak> - Decomp_Initial, // <initial> - Decomp_Medial, // <medial> - Decomp_Final, // <final> - Decomp_Isolated, // <isolated> - Decomp_Encircled, // <circle> - Decomp_Superscript, // <super> - Decomp_Subscript, // <sub> - Decomp_Vertical, // <vertical> - Decomp_Wide, // <wide> - Decomp_Narrow, // <narrow> - Decomp_Small, // <small> - Decomp_Square, // <square> - Decomp_Fraction, // <fraction> - Decomp_Compat // <compat> - }; + bool isDefined() const throw(); - //! Canonical Combining Class - enum CombiningClass { - Combining_Spacing = 0, - Combining_Overlays = 1, - Combining_Nuktas = 7, - Combining_VoicingMarks = 8, - Combining_Viramas = 9, - Combining_FixedStart = 10, - Combining_FixedEnd = 199, - Combining_BelowLeftAttached = 200, - Combining_BelowAttached = 202, - Combining_BelowRightAttached = 204, - Combining_LeftAttached = 208, - Combining_RightAttached = 210, - Combining_AboveLeftAttached = 212, - Combining_AboveAttached = 214, - Combining_AboveRightAttached = 216, - Combining_BelowLeft = 218, - Combining_Below = 220, - Combining_BelowRight = 222, - Combining_Left = 224, - Combining_Right = 226, - Combining_AboveLeft = 228, - Combining_Above = 230, - Combining_AboveRight = 232, - Combining_DoubleBelow = 233, - Combining_DoubleAbove = 234, - Combining_IotaSubscript = 240 - }; + bool isAlphabetic() const throw(); + bool isAlphaNumeric() const throw(); - Char(uchar_t ch = 0); - Char(const Char& ch); + bool isDigit() const throw(); + int digitValue() const throw(); - bool isLetter() const; + bool isNumeric() const throw(); + double numericValue() const throw(); - bool isSymbol() const; - bool isPunct() const; - bool isMark() const; + bool isLower() const throw(); + Char toLower() const throw(); - bool isNumber() const; - float toNumber() const; + bool isUpper() const throw(); + Char toUpper() const throw(); - bool isLower() const; - Char toLower() const; + bool isTitle() const throw(); + Char toTitle() const throw(); - bool isUpper() const; - Char toUpper() const; + bool isMirrored() const throw(); + Char mirrorChar() const throw(); - bool isMirrored() const; + bool isWhiteSpace() const throw(); - Category category() const; - BidiClass bidiClass() const; - Decomposition decompTag() const; - CombiningClass combiningClass() const; + bool isIgnorable() const throw(); - operator const uchar_t& () const throw(); + operator const uchar32_t& () const throw(); - Char& operator=(uchar_t ch); - Char& operator=(const Char& ch); + Char& operator=(uchar32_t ch) throw(InvalidCharError); + Char& operator=(const Char& ch) throw(); - bool operator==(const Char& ch) const; - bool operator!=(const Char& ch) const; + bool operator==(const Char& ch) const throw(); + bool operator!=(const Char& ch) const throw(); - bool operator<(const Char& ch) const; - bool operator>(const Char& ch) const; + bool operator<(const Char& ch) const throw(); + bool operator>(const Char& ch) const throw(); - bool operator<=(const Char& ch) const; - bool operator>=(const Char& ch) const; + bool operator<=(const Char& ch) const throw(); + bool operator>=(const Char& ch) const throw(); - static const Char& eof(); - static const Char& nl(); - static const Char& cr(); + static const Char& eof() throw(); + static const Char& nl() throw(); + static const Char& cr() throw(); private: - uchar_t _char; - + uchar32_t _char; }; } // !namespace Unicode Index: String.h =================================================================== RCS file: /cvsroot/pclasses/pclasses2/include/pclasses/Unicode/String.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- String.h 28 Apr 2005 10:15:01 -0000 1.5 +++ String.h 20 May 2005 14:11:32 -0000 1.6 @@ -24,8 +24,8 @@ #include <pclasses/Export.h> #include <pclasses/BasicTypes.h> #include <pclasses/Alloc.h> +#include <pclasses/SharedPtr.h> #include <pclasses/Unicode/Char.h> -#include <pclasses/Unicode/ustring.h> #include <string> @@ -40,13 +40,21 @@ npos = (size_t)-1 }; - typedef ustring::size_type size_type; - typedef ustring::const_iterator const_iterator; - typedef ustring::iterator iterator; + typedef size_t size_type; + + class Iterator; + class ConstIterator; + + typedef Iterator iterator; + typedef ConstIterator const_iterator; String(); + String(size_t sz); + String(const String& str); - String(const ustring& str); + String(const String& str, size_t offset, size_t count = npos); + + String(const Char* str, size_t count = npos); String(const std::string& str); String(const char* str, size_t count = npos); @@ -58,14 +66,18 @@ bool empty() const throw(); size_t size() const throw(); - const Char& at(size_t index) const; - Char& at(size_t index); + size_t capacity() const throw(); + void resize(size_t sz); + + Char at(size_t index) const; String substr(size_t offset = 0, size_t length = npos) const; String left(size_t length) const; String right(size_t length) const; + int compare(const String& str) const throw(); + String& append(const String& str); String& append(const Char& ch); @@ -87,11 +99,9 @@ size_t find_last_not_of(const String& str, size_t pos = npos) const; size_t find_last_not_of(const Char& ch, size_t pos = npos) const; - Char& operator[](size_t pos); - const Char& operator[](size_t pos) const; + Char operator[](size_t pos) const; String& operator=(const String& str); - String& operator=(const ustring& str); String& operator=(const char* str); String& operator=(const std::string& str); @@ -111,9 +121,6 @@ //! Returns the string in local encoding std::string local() const; - //! Returns the string in latin1 encoding - std::string latin1() const; - //! Returns the string in utf8 encoding std::string utf8() const; @@ -121,8 +128,6 @@ static String fromLocal(const char* str, size_t count = npos); - static String fromLatin1(const char* str, size_t count = npos); - static String fromUtf8(const char* str, size_t count = npos); static String fromUcs2(const char* str, size_t count); @@ -131,7 +136,12 @@ size_t count); private: - ustring _str; + struct Data; + + static Data* alloc(size_t size); + void deepCopy(); + + SharedPtr<Data> _data; }; PUNICODE_EXPORT String operator+(const String& lhs, const String& rhs); |