home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IDBCSBUF.HPP < prev    next >
C/C++ Source or Header  |  1993-10-22  |  11KB  |  209 lines

  1. #ifndef _IDBCSBUF_
  2. #define _IDBCSBUF_
  3. /*******************************************************************************
  4. * FILE NAME: idbcsbuf.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   This file contains the declaration(s) of the class(es):                    *
  8. *     IDBCSBuffer - DBCS buffer class                                          *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   Licensed Materials - Property of IBM                                       *
  12. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  13. *   All Rights Reserved                                                        *
  14. *   US Government Users Restricted Rights - Use, duplication, or               *
  15. *   disclosure                                                                 *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  17. *                                                                              *
  18. *******************************************************************************/
  19. #ifndef _IBUFFER_
  20.   #include <ibuffer.hpp>
  21. #endif
  22.  
  23. /*----------------------------------------------------------------------------*/
  24. /* Align classes on four byte boundary.                                       */
  25. /*----------------------------------------------------------------------------*/
  26. #pragma pack(4)
  27.  
  28. class IDBCSBuffer : public IBuffer {
  29. /*******************************************************************************
  30. * The IDBCSBuffer class implements the version of IString contents that        *
  31. * supports mixed OS/2 double-byte character set (DBCS) characters.  This       *
  32. * class ensures that DBCS multi-byte characters are processed properly.        *
  33. *                                                                              *
  34. * The use of this class is transparent to the user of class IString.           *
  35. *******************************************************************************/
  36. public:
  37. /*-------------------------------- Overrides -----------------------------------
  38. | This class re-implements the following IBuffer functions as public:          |
  39. |   subString            - See IBuffer::subString.                             |
  40. |   charType             - See IBuffer::charType.                              |
  41. |   allocate             - See IBuffer::allocate.                              |
  42. |   next                 - See IBuffer::next.                                  |
  43. |                                                                              |
  44. | This class re-implements the following IString version of IBuffer functions: |
  45. |   isDBCS               - See IString::isDBCS.                                |
  46. |   isSBCS               - See IString::isDBCS.                                |
  47. |   isValidDBCS          - See IString::isValidDBCS.                           |
  48. |   includesDBCS         - See IString::includesDBCS.                          |
  49. |   includesSBCS         - See IString::includesSBCS.                          |
  50. |   indexOf              - See IString::indexOf.                               |
  51. |   indexOfAnyBut        - See IString::indexOfAnyBut.                         |
  52. |   indexOfAnyOf         - See IString::indexOfAnyOf.                          |
  53. |   lastIndexOf          - See IString::lastIndexOf.                           |
  54. |   lastIndexOfAnyBut    - See IString::lastIndexOfAnyBut.                     |
  55. |   lastIndexOfAnyOf     - See IString::lastIndexOfAnyOf.                      |
  56. |   center               - See IString::center.                                |
  57. |   insert               - See IString::insert.                                |
  58. |   leftJustify          - See IString::leftJustify.                           |
  59. |   lowerCase            - See IString::lowerCase.                             |
  60. |   overlayWith          - See IString::overlayWith.                           |
  61. |   remove               - See IString::remove.                                |
  62. |   reverse              - See IString::reverse.                               |
  63. |   rightJustify         - See IString::rightJustify.                          |
  64. |   strip                - See IString::strip.                                 |
  65. |   translate            - See IString::translate.                             |
  66. |   upperCase            - See IString::upperCase.                             |
  67. |   className            - Returns "IDBCSBuffer".                              |
  68. ------------------------------------------------------------------------------*/
  69. IBuffer
  70.  *subString ( unsigned startPos,
  71.               unsigned len,
  72.               char     padCharacter ) const;
  73.  
  74. Boolean
  75.   isDBCS       ( ) const,
  76.   isSBCS       ( ) const,
  77.   isValidDBCS  ( ) const,
  78.   includesDBCS ( ) const,
  79.   includesSBCS ( ) const;
  80.  
  81. IStringEnum::CharType
  82.   charType ( unsigned index ) const;
  83.  
  84. unsigned
  85.   indexOf           ( const IStringTest &aTest,
  86.                       unsigned           startPos = 1 ) const,
  87.   indexOf           ( const char        *pString,
  88.                       unsigned           len,
  89.                       unsigned           startPos = 1 ) const,
  90.   indexOfAnyBut     ( const char        *pString,
  91.                       unsigned           len,
  92.                       unsigned           startPos = 1 ) const,
  93.   indexOfAnyBut     ( const IStringTest &aTest,
  94.                       unsigned           startPos = 1 ) const,
  95.   indexOfAnyOf      ( const char        *pString,
  96.                       unsigned           len,
  97.                       unsigned           startPos = 1 ) const,
  98.   indexOfAnyOf      ( const IStringTest &aTest,
  99.                       unsigned           startPos = 1 ) const,
  100.   lastIndexOf       ( const IStringTest &aTest,
  101.                       unsigned           startPos = 1 ) const,
  102.   lastIndexOf       ( const char        *pString,
  103.                       unsigned           len,
  104.                       unsigned           startPos = 0 ) const,
  105.   lastIndexOfAnyBut ( const char        *pString,
  106.                       unsigned           len,
  107.                       unsigned           startPos = 0 ) const,
  108.   lastIndexOfAnyBut ( const IStringTest &aTest,
  109.                       unsigned           startPos = 0 ) const,
  110.   lastIndexOfAnyOf  ( const char        *pString,
  111.                       unsigned           len,
  112.                       unsigned           startPos = 0 ) const,
  113.   lastIndexOfAnyOf  ( const IStringTest &aTest,
  114.                       unsigned           startPos = 0 ) const;
  115.  
  116. IBuffer
  117.  *center       ( unsigned newLen,
  118.                  char     padCharacter ),
  119.  *insert       ( const char *pInsert,
  120.                  unsigned    insertLen,
  121.                  unsigned    pos,
  122.                  char        padCharacter ),
  123.  *leftJustify  ( unsigned newLen,
  124.                  char     padCharacter ),
  125.  *lowerCase    ( ),
  126.  *overlayWith  ( const char *overlay,
  127.                  unsigned    len,
  128.                  unsigned    pos,
  129.                  char        padCharacter ),
  130.  *remove       ( unsigned startPos,
  131.                  unsigned numChars ),
  132.  *reverse      ( ),
  133.  *rightJustify ( unsigned newLen,
  134.                  char     padCharacter ),
  135.  *strip        ( const char             *pChars,
  136.                  unsigned                len,
  137.                  IStringEnum::StripMode  mode ),
  138.  *strip        ( const IStringTest      &aTest,
  139.                  IStringEnum::StripMode  mode ),
  140.  *translate    ( const char *pInputChars,
  141.                  unsigned    inputLen,
  142.                  const char *pOutputChars,
  143.                  unsigned    outputLen,
  144.                  char        padCharacter ),
  145.  *upperCase    ( );
  146.  
  147. IBuffer
  148.  *allocate ( unsigned newLen ) const;
  149.  
  150. char
  151.  *next ( const char *prev );
  152.  
  153. const char
  154.  *next ( const char *prev ) const;
  155.  
  156. protected:
  157. /*---------------------- Protected Overrides -----------------------------------
  158. | This class re-implements the following IBuffer functions as protected:       |
  159. |                                                                              |
  160. |   startSearch          - See IBuffer::startSearch.                           |
  161. |   startBackwardsSearch - See IBuffer::startBackwardsSearch.                  |
  162. |   className            - Returns "IDBCSBuffer".                              |
  163. ------------------------------------------------------------------------------*/
  164.  
  165. unsigned
  166.   startSearch          ( unsigned startPos,
  167.                          unsigned searchLen ) const,
  168.   startBackwardsSearch ( unsigned startPos,
  169.                          unsigned searchLen ) const;
  170.  
  171. const char
  172.  *className ( ) const;
  173.  
  174. /*------------------------------ Implementation --------------------------------
  175. | These functions provide services used to implement this class:               |
  176. |   isCharValid - Returns true if and only if the character at the given       |
  177. |                 index is in the set of valid characters.                     |
  178. |   isDBCS1     - Returns true if and only if the byte at the given offset     |
  179. |                 is the first byte of DBCS.                                   |
  180. |   isPrevDBCS  - Returns true if and only if the preceding character to the   |
  181. |                 one at the given offset is a DBCS character.                 |
  182. ------------------------------------------------------------------------------*/
  183. Boolean
  184.   isCharValid ( unsigned    pos,
  185.                 const char *pValidChars,
  186.                 unsigned    numValidChars ) const,
  187.   isDBCS1     ( unsigned    pos ) const,
  188.   isPrevDBCS  ( unsigned    pos ) const;
  189.  
  190. friend class IBuffer;
  191. /*------------------------------- Constructor ----------------------------------
  192. | The constructor for this class is protected.  It is only called from the     |
  193. | member function allocate and the static member function IBuffer::initialize. |
  194. ------------------------------------------------------------------------------*/
  195.   IDBCSBuffer ( unsigned bufLength );
  196.   ~IDBCSBuffer ( );
  197. }; // class IDBCSBuffer
  198.  
  199. /*----------------------------------------------------------------------------*/
  200. /* Resume compiler default packing.                                           */
  201. /*----------------------------------------------------------------------------*/
  202. #pragma pack()
  203.  
  204. #ifndef I_NO_INLINES
  205.   #include <idbcsbuf.inl>
  206. #endif
  207.  
  208. #endif // _IDBCSBUF_
  209.