//============================================================================= // drt/sys/schar3.cpp // Unicode character classes. // // These classes provide a representation of Unicode characters. // // History // 0.01, 1998-04-19, David R Tribble. // First cut. // // 0.02, 1998-04-27, David R Tribble. // Split file into "jchar1.cpp", "jchar2.cpp", and "jchar3.cpp". // // 0.03, 1998-05-30, David R Tribble. // Changed filename prefix from "j" to "s". // // 0.04, 1999-02-26, David R Tribble. // Moved to drt/sys/. // // Copyright ©1998-1999, by David R. Tribble, all rights reserved. // See "drt/sys/copyr.txt" for more information. //----------------------------------------------------------------------------- // Identification static const char id[] = "@(#)drt/sys/schar3.cpp 0.04"; // System includes #include #define drt_std_assert_h 1 #include #define drt_std_ctype_h 1 // Special includes #include "sdefs.hpp" // Local includes #include "sdebug.hpp" #include "schar.hpp" // Local wrappers #include "slib1.hpp" drt_namespace_begin //----------------------------------------------------------------------------- // Class member functions //----------------------------------------------------------------------------- // Note: No destructor // Note: No default constructor // Note: No copy constructor //----------------------------------------------------------------------------- // DrtChar::validate() // Validate this object. // // Notes // Fails an assert() if this object is invalid. //----------------------------------------------------------------------------- void DrtChar::validate() const { #if DrtChar_VS/100 != 1 #error DrtChar_VS has changed #endif //DrtTrace dbg(s_grp, "validate", this); // Validate this object assert(("DrtChar", this != null)); // Check for null // Note: No other checks are performed } //----------------------------------------------------------------------------- // DrtChar::dump() // Dump the contents of this object to the debugging trace output. //----------------------------------------------------------------------------- void DrtChar::dump() const { #if DrtChar_VS/100 != 1 #error DrtChar_VS has changed #endif //DrtTrace dbg(s_grp, "dump", this); // Validate this object validate(); // Lock the debug output context DrtTrace::enterContext(); // Dump the contents of this object DrtTrace::print(".m_ch ......... %04X", m_ch); if (isPrint_8()) DrtTrace::print(" '%c'", m_ch); DrtTrace::print("\n"); // Done DrtTrace::leaveContext(); } //----------------------------------------------------------------------------- // DrtChar::isNull() // Check that this character is a null character (NUL). // // Returns // True if this character is NUL, otherwise false. //----------------------------------------------------------------------------- bool DrtChar::isNull() const { #if DrtChar_VS/100 != 1 #error DrtChar_VS has changed #endif //DrtTrace dbg(&s_grp, "isNull", this); // Check the character code return (m_ch == C_NUL); } //----------------------------------------------------------------------------- // DrtChar::isPrint_8() // Check that this character is printable as an 8-bit ASCII (ISO-8859-1) // character. // // Returns // True if this character is printable, otherwise false. //----------------------------------------------------------------------------- bool DrtChar::isPrint_8() const { #if DrtChar_VS/100 != 1 #error DrtChar_VS has changed #endif //DrtTrace dbg(&s_grp, "isPrint_8", this); // Check the character code if (m_ch >= 0x0100) return (false); if (m_ch < C_SP) return (false); if (m_ch < C_DEL) return (true); if (m_ch >= C_NBSP) return (true); return (false); } //----------------------------------------------------------------------------- // DrtChar::isEoln() // Check that this character is an end-of-line character. // // Returns // True if this character is an eoln character, otherwise false. //----------------------------------------------------------------------------- bool DrtChar::isEoln() const { #if DrtChar_VS/100 != 1 #error DrtChar_VS has changed #endif //DrtTrace dbg(&s_grp, "isEoln", this); // Check the character code switch (m_ch) { case C_CR: case C_LF: case C_VT: case C_EOLN: // Is an end-of-line character return (true); default: // Is not return (false); } } //----------------------------------------------------------------------------- #if is_incomplete___ bool isSpace() const; // Is space char bool isWhite() const; // Is whitespace char bool isControl() const; // Is control char bool isPrint() const; // Is printable bool isAlnum() const; // Is alphanumeric bool isDigit() const; // Is a digit bool isASCII_7() const; // Is 7-bit ASCII/ISO-646 bool isISO_8859_1() const; // Is 8-bit ISO-8859-1/Latin-1 int toUTF_7(char *s); // Convert to UTF-7 seq int toUTF_8(char *s); // Convert to UTF-8 seq int toISO_8859_1(char *s); // Convert to ISO-8859-1 seq int fromUTF_7(const char *s); // Convert from UTF-7 seq int fromUTF_8(const char *s); // Convert from UTF-8 seq int fromISO_8859_1(const char *s); // Convert from ISO-8859-1 seq bool operator ==(const DrtChar &o) const; // Compare to another char bool operator !=(const DrtChar &o) const; // Compare to another char bool operator <(const DrtChar &o) const; // Compare to another char bool operator >(const DrtChar &o) const; // Compare to another char bool operator <=(const DrtChar &o) const; // Compare to another char bool operator >=(const DrtChar &o) const; // Compare to another char ...............INCOMPLETE.................. #endif drt_namespace_end // End schar3.cpp