home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample PMSAM / PMSAM Framework / Common / PascalString.h < prev    next >
Encoding:
Text File  |  1995-07-28  |  20.2 KB  |  764 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        PascalString.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Tim Harnett
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <3>     2/21/95    TMH        copied new MacApp version to be metrowerks compatible
  13.          <2>     9/28/94    DOR        Added an include for textutils.h which is necessary for
  14.                                     RelString to work with the MPW 3.3 headers.
  15.          <1>     9/20/94    TMH        Abandon RoadsideRest embrace Mercury
  16.  
  17.     To Do:
  18. */
  19.  
  20. //----------------------------------------------------------------------------------------
  21. // PascalString.h 
  22. // Copyright © 1985-1994 by Apple Computer, Inc.  All rights reserved.
  23. //----------------------------------------------------------------------------------------
  24. // • Updated by Jeroen Schalk - DTS
  25. // • Use MABlockMove, not memcpy(), memmove(), strncpy().
  26. // • Changed default constructors to initialize to empty string.
  27. // • Changed number of temporary strings from 4 to 8
  28. // • Make operator[] and unsigned char*() inline
  29. // • Fix bugs in constructors out of const unsigned char* str
  30. // • Optimized constructors to only move required data
  31. // • General cleanup of code for readability
  32.  
  33.  
  34. #ifndef __PASCALSTRING__
  35. #define __PASCALSTRING__
  36.  
  37. #ifndef __MEMORY__
  38. #include <Memory.h>
  39. #endif
  40.  
  41. #ifndef __TYPES__
  42. #include <Types.h>
  43. #endif
  44.  
  45. #ifndef __TEXTUTILS__
  46. #include <TextUtils.h>
  47. #endif
  48.  
  49. #ifndef __OSUTILS__
  50. #include <OSUtils.h>
  51. #endif
  52.  
  53. #ifndef __STRING__
  54. #include <string.h>
  55. #endif
  56.  
  57. // If Length() is defined as a macro in Types.h, undefine it
  58. // so we can have member functions with the same name
  59. #ifdef Length
  60. #undef Length
  61. #endif
  62.  
  63. // Forward declaration for all the CString classes.
  64. struct CString;
  65. struct CStr255;
  66. struct CStr63;
  67. struct CStr32;
  68. struct CStr31;
  69.  
  70. typedef const CStr255& ConstCStr255Param;
  71. typedef const CStr63& ConstCStr63Param;
  72. typedef const CStr32& ConstCStr32Param;
  73. typedef const CStr31& ConstCStr31Param;
  74.  
  75. // Some constants defining the length of each of the CString types.
  76.  
  77. const short kLengthByte = 1;
  78. const short kBaseLen = 2;
  79. const short kStr255Len = 255;
  80. const short kStr63Len = 63;
  81. const short kStr32Len = 32;
  82. const short kStr31Len = 31;
  83.  
  84. // Number of temporary strings
  85.  
  86. const short kTempCStrings = 8;
  87.  
  88. //----------------------------------------------------------------------------------------
  89. // MABlockMove: BlockMoveData() is fastest on PowerPC, memcpy() on 68K
  90. //----------------------------------------------------------------------------------------
  91.  
  92. #if qPowerPC
  93.     #define MABlockMove(srcPtr, destPtr, byteCount) \
  94.         ::BlockMoveData(Ptr(srcPtr), Ptr(destPtr), Size(byteCount))
  95. #else
  96.     #define MABlockMove(srcPtr, destPtr, byteCount) \
  97.         ::memcpy(destPtr, srcPtr, size_t(byteCount))
  98. #endif
  99.  
  100. //----------------------------------------------------------------------------------------
  101. // MABlockMoveOverlap: BlockMoveData() is fastest on PowerPC, memmove() on 68K
  102. //----------------------------------------------------------------------------------------
  103.  
  104. #if qPowerPC
  105.     #define MABlockMoveOverlap(srcPtr, destPtr, byteCount) \
  106.         ::BlockMoveData(Ptr(srcPtr), Ptr(destPtr), Size(byteCount))
  107. #else
  108.     #define MABlockMoveOverlap(srcPtr, destPtr, byteCount) \
  109.         ::memmove(destPtr, srcPtr, size_t(byteCount))
  110. #endif
  111.  
  112. //----------------------------------------------------------------------------------------
  113. // CString: Superclass of all Pascal string compatible string classes.
  114. //----------------------------------------------------------------------------------------
  115.  
  116. typedef struct CString *CStringPtr, **CStringHandle;
  117.  
  118. struct CString
  119. {
  120. public:
  121.     unsigned char fStr[kBaseLen];
  122.  
  123. protected:
  124.     void InsertHelper(const CString& insStr, short pos, short maxLength);
  125.     void InsertHelper(const char* insStr, short pos, short maxLength);
  126.  
  127. public:
  128.     // Basic length method, inherited by all derived classes. Define one that returns a
  129.     // reference. Can be used as an lvalue and only can be applied to non-const Strings.
  130.  
  131.     inline unsigned char& Length()
  132.     {
  133.         return fStr[0];
  134.     }                                            // for non-const CString
  135.  
  136.     inline unsigned char Length() const
  137.     {
  138.         return fStr[0];
  139.     }                                            // for const CString
  140.  
  141.     inline Boolean IsEmpty()
  142.     {
  143.         return fStr[0] <= 0;
  144.     }                                            // for non-const CString
  145.  
  146.     inline Boolean IsEmpty() const
  147.     {
  148.         return fStr[0] <= 0;
  149.     }                                            // for const CString
  150.  
  151.     // Character selector operator.
  152.  
  153.     inline unsigned char& operator[](short pos)
  154.     {
  155.         return fStr[pos];
  156.     }                                            // for non-const CString
  157.  
  158.     inline unsigned char operator[](short pos) const
  159.     {
  160.         return fStr[pos];
  161.     }                                            // for const CString
  162.     
  163.     //------------------------------------------------------------------------------------
  164.     // CAUTION: There is a subtle difference between the (char*) and (unsigned char*)
  165.     // conversion operators. The first converts a pascal-style string to a c-style
  166.     // string. The second simply converts between two types (CString and Str55) both of
  167.     // which are pascal-style strings.
  168.     
  169.     // Create a NULL terminated c-style string from a pascal-style CString. Used in
  170.     // debugging to fprintf a CString.
  171.     
  172.     operator char*() const;
  173.     
  174.     // Used to create a toolbox type Str255 from our CString. This is simply a type
  175.     // coercion! Both CString and Str255 are expected to be pascal-style strings.
  176.     
  177.     inline operator unsigned char*()
  178.     {
  179.         return (unsigned char *) this;
  180.     }                                            // for non-const CString
  181.     
  182.     operator const unsigned char*() const;        // for const CString
  183.  
  184.     //------------------------------------------------------------------------------------
  185.     
  186.     // Return an ID represented as a CString to the actual ID (a long).
  187.     
  188.     operator long() const;
  189.  
  190.     // Relational operators that are inherited by all the derived CString types. Three of
  191.     // each so that literal C Strings can be conveniently used for one of the operators as
  192.     // well as two of the derive classes as operators. These are declared here but defined
  193.     // below all the CString classes because they use constructors for CStr255 and its class
  194.     // definition has not been encountered yet.
  195.  
  196.     friend inline Boolean operator==(const CString& s1,
  197.                                      const char* s2);
  198.     friend inline Boolean operator==(const char* s1,
  199.                                      const CString& s2);
  200.     friend inline Boolean operator==(const CString& s1,
  201.                                      const CString& s2);
  202.  
  203.     friend inline Boolean operator!=(const CString& s1,
  204.                                      const char* s2);
  205.     friend inline Boolean operator!=(const char* s1,
  206.                                      const CString& s2);
  207.     friend inline Boolean operator!=(const CString& s1,
  208.                                      const CString& s2);
  209.  
  210.     friend inline Boolean operator>(const CString& s1,
  211.                                     const char* s2);
  212.     friend inline Boolean operator>(const char* s1,
  213.                                     const CString& s2);
  214.     friend inline Boolean operator>(const CString& s1,
  215.                                     const CString& s2);
  216.  
  217.     friend inline Boolean operator<(const CString& s1,
  218.                                     const char* s2);
  219.     friend inline Boolean operator<(const char* s1,
  220.                                     const CString& s2);
  221.     friend inline Boolean operator<(const CString& s1,
  222.                                     const CString& s2);
  223.  
  224.     friend inline Boolean operator>=(const CString& s1,
  225.                                      const char* s2);
  226.     friend inline Boolean operator>=(const char* s1,
  227.                                      const CString& s2);
  228.     friend inline Boolean operator>=(const CString& s1,
  229.                                      const CString& s2);
  230.  
  231.     friend inline Boolean operator<=(const CString& s1,
  232.                                      const char* s2);
  233.     friend inline Boolean operator<=(const char* s1,
  234.                                      const CString& s2);
  235.     friend inline Boolean operator<=(const CString& s1,
  236.                                      const CString& s2);
  237.  
  238.     // Concatenation operator that are inherited by all the derived CString types. Three
  239.     // of each so that literal C Strings can be conveniently used for one of the operators
  240.     // as well as using any two classes derived from CString.
  241.  
  242.     friend CStr255 operator+(const CString& s1,
  243.                              const char* s2);
  244.     friend CStr255 operator+(const char* s1,
  245.                              const CString& s2);
  246.     friend CStr255 operator+(const CString& s1,
  247.                              const CString& s2);
  248.  
  249.     // Methods that mimic the Pascal builtin CString functions for Pos, Insert and Delete.
  250.     // Note that insert and copy is implemented in the derived classes.
  251.  
  252.     unsigned char Pos(const char* subStr, unsigned char startPos = 1);
  253.     unsigned char Pos(const CString& subStr, unsigned char startPos = 1);
  254.     void Delete(short pos, short length);
  255.  
  256. protected:
  257.     inline long Min(const long a, const long b) const
  258.     {
  259.         return a < b ? a : b;
  260.     }
  261. };
  262.  
  263.  
  264. //----------------------------------------------------------------------------------------
  265. // CStr255:
  266. //----------------------------------------------------------------------------------------
  267.  
  268. struct CStr255 : CString
  269. {
  270.     friend struct CStr63;
  271.     friend struct CStr31;
  272.  
  273. private:
  274.     unsigned char fData[kStr255Len - 1];
  275.  
  276. public:
  277.     CStr255();
  278.     CStr255(const CStr255& str);
  279.     CStr255(const CStr63& str);
  280.     CStr255(const CStr32& str);
  281.     CStr255(const CStr31& str);
  282.     CStr255(const unsigned char* str);
  283.     CStr255(const char* str);
  284.     CStr255(const long id);
  285.  
  286.     // Insert and Copy roughly equivalent to the Pascal Insert and Copy functions.
  287.     
  288.     void Insert(const CString& str, short pos);
  289.     void Insert(const char* str, short pos);
  290.     CStr255 Copy(short pos, short length);
  291.                        
  292.     // Concatenation operator
  293.     
  294.     CStr255& operator +=(const CString& str);
  295.     CStr255& operator +=(const char* str);
  296.     CStr255& operator +=(const char ch);
  297.  
  298.     // Assignment operator
  299.  
  300.     CStr255& operator =(const CStr255& str);
  301.     CStr255& operator =(const CStr63& str);
  302.     CStr255& operator =(const CStr32& str);
  303.     CStr255& operator =(const CStr31& str);
  304.     CStr255& operator =(const unsigned char* str);
  305.     CStr255& operator =(const char aChar);
  306.     CStr255& operator =(const char* str);
  307. };
  308.  
  309.  
  310. //----------------------------------------------------------------------------------------
  311. // CStr63:
  312. //----------------------------------------------------------------------------------------
  313.  
  314. struct CStr63 : CString
  315. {
  316.     friend struct CStr255;
  317.     friend struct CStr31;
  318.  
  319. private:
  320.     unsigned char fData[kStr63Len - 1];
  321.  
  322. public:
  323.     CStr63();
  324.     CStr63(const CStr255& str);
  325.     CStr63(const CStr63& str);
  326.     CStr63(const CStr32& str);
  327.     CStr63(const CStr31& str);
  328.     CStr63(const unsigned char* str);
  329.     CStr63(const char* str);
  330.     CStr63(const long id);
  331.  
  332.     // Insert and Copy roughly equivalent to the Pascal Insert and Copy functions.
  333.     
  334.     void Insert(const CString& str, short pos);
  335.     void Insert(const char* str, short pos);
  336.     CStr63 Copy(short pos, short length);
  337.  
  338.     // Concatenation operator
  339.     
  340.     CStr63& operator +=(const CString& str);
  341.     CStr63& operator +=(const char* str);
  342.     CStr63& operator +=(const char ch);
  343. };
  344.  
  345.  
  346. //----------------------------------------------------------------------------------------
  347. // CStr32:
  348. //----------------------------------------------------------------------------------------
  349.  
  350. struct CStr32 : CString
  351. {
  352.     friend struct CStr255;
  353.     friend struct CStr63;
  354.  
  355. private:
  356.     unsigned char fData[kStr32Len - 1];
  357.  
  358. public:
  359.     CStr32();
  360.     inline CStr32(unsigned char length)
  361.     {
  362.         fStr[0] = length;
  363.     }
  364.  
  365.     CStr32(const CStr255& str);
  366.     CStr32(const CStr63& str);
  367.     CStr32(const CStr32& str);
  368.     CStr32(const CStr31& str);
  369.     CStr32(const unsigned char* str);
  370.     CStr32(const char* str);
  371.     CStr32(const long id);
  372.  
  373.     // Insert and Copy roughly equivalent to the Pascal Insert and Copy functions.
  374.     
  375.     void Insert(const CString& str, short pos);
  376.     void Insert(const char* str, short pos);
  377.     CStr32 Copy(short pos, short length);
  378.  
  379.     // Concatenation operator
  380.     
  381.     CStr32& operator +=(const CString& str);
  382.     CStr32& operator +=(const char* str);
  383.     CStr32& operator +=(const char ch);
  384. };
  385.  
  386.  
  387. //----------------------------------------------------------------------------------------
  388. // CStr31:
  389. //----------------------------------------------------------------------------------------
  390.  
  391. struct CStr31 : CString
  392. {
  393.     friend struct CStr255;
  394.     friend struct CStr63;
  395.     friend struct CStr32;
  396.  
  397. private:
  398.     unsigned char fData[kStr31Len - 1];
  399.  
  400. public:
  401.     CStr31();
  402.     inline CStr31(unsigned char length)
  403.     {
  404.         fStr[0] = length;
  405.     }
  406.  
  407.     CStr31(const CStr255& str);
  408.     CStr31(const CStr63& str);
  409.     CStr31(const CStr32& str);
  410.     CStr31(const CStr31& str);
  411.     CStr31(const unsigned char* str);
  412.     CStr31(const char* str);
  413.     CStr31(const long id);
  414.  
  415.     // Insert and Copy roughly equivalent to the Pascal Insert and Copy functions.
  416.     
  417.     void Insert(const CString& str, short pos);
  418.     void Insert(const char* str, short pos);
  419.     CStr31 Copy(short pos, short length);
  420.  
  421.     // Concatenation operator
  422.     
  423.     CStr31& operator +=(const CString& str);
  424.     CStr31& operator +=(const char* str);
  425.     CStr31& operator +=(const char ch);
  426. };
  427.  
  428. //----------------------------------------------------------------------------------------
  429. // CStr255 inline function definitions
  430. //----------------------------------------------------------------------------------------
  431.  
  432. inline CStr255::CStr255()
  433. {
  434.     fStr[0] = 0;
  435. }
  436.  
  437. inline CStr255::CStr255(const CStr255& str)
  438. {
  439.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  440. }
  441.  
  442. inline CStr255::CStr255(const CStr63& str)
  443. {
  444.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  445. }
  446.  
  447. inline CStr255::CStr255(const CStr32& str)
  448. {
  449.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  450. }
  451.  
  452. inline CStr255::CStr255(const CStr31& str)
  453. {
  454.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  455. }
  456.  
  457. inline CStr255::CStr255(const unsigned char* str)
  458. {
  459.     MABlockMove(str, fStr, str[0] + kLengthByte);
  460. }
  461.  
  462. inline CStr255& CStr255::operator = (const CStr255& str)
  463. {
  464.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  465.     
  466.     return *this;
  467. }
  468.  
  469. inline CStr255& CStr255::operator = (const CStr63& str)
  470. {
  471.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  472.     
  473.     return *this;
  474. }
  475.  
  476. inline CStr255& CStr255::operator = (const CStr32& str)
  477. {
  478.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  479.     
  480.     return *this;
  481. }
  482.  
  483. inline CStr255& CStr255::operator = (const CStr31& str)
  484. {
  485.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  486.     
  487.     return *this;
  488. }
  489.  
  490. inline CStr255& CStr255::operator = (const unsigned char* str)
  491. {
  492.     MABlockMove(str, fStr, str[0] + kLengthByte);
  493.     
  494.     return *this;
  495. }
  496.  
  497. inline CStr255& CStr255::operator = (const char aChar)
  498. {
  499.     Length() = (aChar) ? 1 : 0;
  500.     fStr[1] = aChar;
  501.     
  502.     return *this;
  503. }
  504.  
  505. inline void CStr255::Insert(const CString& str, short pos)
  506. {
  507.     this->InsertHelper(str, pos, kStr255Len);
  508. }
  509.  
  510. inline void CStr255::Insert(const char* str, short pos)
  511. {
  512.     this->InsertHelper(str, pos, kStr255Len);
  513. }
  514.  
  515.  
  516. //----------------------------------------------------------------------------------------
  517. // CStr63 inline function definitions
  518. //----------------------------------------------------------------------------------------
  519.  
  520. inline CStr63::CStr63()
  521. {
  522.     fStr[0] = 0;
  523. }
  524.  
  525. inline CStr63::CStr63(const CStr255& str)
  526. {
  527.     // Truncate the CStr255 to 63 bytes if necessary.
  528.  
  529.     Length() = str.Length() > kStr63Len ? kStr63Len : str.Length();
  530.     MABlockMove(&str.fStr[1], &fStr[1], Length());
  531. }
  532.  
  533. inline CStr63::CStr63(const CStr63& str)
  534. {
  535.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  536. }
  537.  
  538. inline CStr63::CStr63(const CStr32& str)
  539. {
  540.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  541. }
  542.  
  543. inline CStr63::CStr63(const CStr31& str)
  544. {
  545.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  546. }
  547.  
  548. inline CStr63::CStr63(const unsigned char* str)
  549. {
  550.     MABlockMove(str, fStr, Min(str[0] + kLengthByte, sizeof(CStr63)));
  551. }
  552.  
  553. inline void CStr63::Insert(const CString& str, short pos)
  554. {
  555.     this->InsertHelper(str, pos, kStr63Len);
  556. }
  557.  
  558. inline void CStr63::Insert(const char* str, short pos)
  559. {
  560.     this->InsertHelper(str, pos, kStr63Len);
  561. }
  562.  
  563.  
  564. //----------------------------------------------------------------------------------------
  565. // CStr32 inline function definitions
  566. //----------------------------------------------------------------------------------------
  567.  
  568. inline CStr32::CStr32()
  569. {
  570.     fStr[0] = 0;
  571. }
  572.  
  573. inline CStr32::CStr32(const CStr255& str)
  574. {
  575.     // Truncate the CStr255 to 32 bytes if necessary.
  576.  
  577.     Length() = str.Length() > kStr32Len ? kStr32Len : str.Length();
  578.     MABlockMove(&str.fStr[1], &fStr[1], Length());
  579. }
  580.  
  581. inline CStr32::CStr32(const CStr63& str)
  582. {
  583.     // Truncate the CStr63 to 32 bytes if necessary.
  584.  
  585.     Length() = str.Length() > kStr32Len ? kStr32Len : str.Length();
  586.     MABlockMove(&str.fStr[1], &fStr[1], Length());
  587. }
  588.  
  589. inline CStr32::CStr32(const CStr32& str)
  590. {
  591.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  592. }
  593.  
  594. inline CStr32::CStr32(const CStr31& str)
  595. {
  596.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  597. }
  598.  
  599. inline CStr32::CStr32(const unsigned char* str)
  600. {
  601.     MABlockMove(str, fStr, Min(str[0] + kLengthByte, sizeof(CStr32)));
  602. }
  603.  
  604. inline void CStr32::Insert(const CString& str, short pos)
  605. {
  606.     this->InsertHelper(str, pos, kStr32Len);
  607. }
  608.  
  609. inline void CStr32::Insert(const char* str, short pos)
  610. {
  611.     this->InsertHelper(str, pos, kStr32Len);
  612. }
  613.  
  614.  
  615. //----------------------------------------------------------------------------------------
  616. // CStr31 inline function definitions
  617. //----------------------------------------------------------------------------------------
  618.  
  619. inline CStr31::CStr31()
  620. {
  621.     fStr[0] = 0;
  622. }
  623.  
  624. inline CStr31::CStr31(const CStr255& str)
  625. {
  626.     // Truncate the CStr255 to 31 bytes if necessary.
  627.  
  628.     Length() = str.Length() > kStr31Len ? kStr31Len : str.Length();
  629.     MABlockMove(&str.fStr[1], &fStr[1], Length());
  630. }
  631.  
  632. inline CStr31::CStr31(const CStr63& str)
  633. {
  634.     // Truncate the CStr63 to 31 bytes if necessary.
  635.  
  636.     Length() = str.Length() > kStr31Len ? kStr31Len : str.Length();
  637.     MABlockMove(&str.fStr[1], &fStr[1], Length());
  638. }
  639.  
  640. inline CStr31::CStr31(const CStr32& str)
  641. {
  642.     // Truncate the CStr32 to 31 bytes if necessary.
  643.  
  644.     Length() = str.Length() > kStr31Len ? kStr31Len : str.Length();
  645.     MABlockMove(&str.fStr[1], &fStr[1], Length());
  646. }
  647.  
  648. inline CStr31::CStr31(const CStr31& str)
  649. {
  650.     MABlockMove(str.fStr, fStr, str.Length() + kLengthByte);
  651. }
  652.  
  653. inline CStr31::CStr31(const unsigned char* str)
  654. {
  655.     MABlockMove(str, fStr, Min(str[0] + kLengthByte, sizeof(CStr31)));
  656. }
  657.  
  658. inline void CStr31::Insert(const CString& str, short pos)
  659. {
  660.     this->InsertHelper(str, pos, kStr31Len);
  661. }
  662.  
  663. inline void CStr31::Insert(const char* str, short pos)
  664. {
  665.     this->InsertHelper(str, pos, kStr31Len);
  666. }
  667.  
  668.  
  669. //----------------------------------------------------------------------------------------
  670. // Inline friend function definitions for relational string operators.
  671. //----------------------------------------------------------------------------------------
  672.  
  673. inline Boolean operator==(const CString& s1, const char* s2)
  674. {
  675.     return ::RelString((ConstStr255Param)&s1, CStr255(s2), false, true) == 0;
  676. }
  677.  
  678. inline Boolean operator==(const char* s1, const CString& s2)
  679. {
  680.     return ::RelString(CStr255(s1), (ConstStr255Param)&s2, false, true) == 0;
  681. }
  682.  
  683. inline Boolean operator==(const CString& s1, const CString& s2)
  684. {
  685.     return ::RelString((ConstStr255Param)&s1, (ConstStr255Param)&s2, false, true) == 0;
  686. }
  687.  
  688. inline Boolean operator!=(const CString& s1, const char* s2)
  689. {
  690.     return ::RelString((ConstStr255Param)&s1, CStr255(s2), false, true) != 0;
  691. }
  692.  
  693. inline Boolean operator!=(const char* s1, const CString& s2)
  694. {
  695.     return ::RelString(CStr255(s1), (ConstStr255Param)&s2, false, true) != 0;
  696. }
  697.  
  698. inline Boolean operator!=(const CString& s1, const CString& s2)
  699. {
  700.     return ::RelString((ConstStr255Param)&s1, (ConstStr255Param)&s2, false, true) != 0;
  701. }
  702.  
  703. inline Boolean operator>(const CString& s1, const char* s2)
  704. {
  705.     return ::RelString((ConstStr255Param)&s1, CStr255(s2), false, true) > 0;
  706. }
  707.  
  708. inline Boolean operator>(const char* s1, const CString& s2)
  709. {
  710.     return ::RelString(CStr255(s1), (ConstStr255Param)&s2, false, true) > 0;
  711. }
  712.  
  713. inline Boolean operator>(const CString& s1, const CString& s2)
  714. {
  715.     return ::RelString((ConstStr255Param)&s1, (ConstStr255Param)&s2, false, true) > 0;
  716. }
  717.  
  718. inline Boolean operator<(const CString& s1, const char* s2)
  719. {
  720.     return ::RelString((ConstStr255Param)&s1, CStr255(s2), false, true) < 0;
  721. }
  722.  
  723. inline Boolean operator<(const char* s1, const CString& s2)
  724. {
  725.     return ::RelString(CStr255(s1), (ConstStr255Param)&s2, false, true) < 0;
  726. }
  727.  
  728. inline Boolean operator<(const CString& s1, const CString& s2)
  729. {
  730.     return ::RelString((ConstStr255Param)&s1, (ConstStr255Param)&s2, false, true) < 0;
  731. }
  732.  
  733. inline Boolean operator>=(const CString& s1, const char* s2)
  734. {
  735.     return ::RelString((ConstStr255Param)&s1, CStr255(s2), false, true) >= 0;
  736. }
  737.  
  738. inline Boolean operator>=(const char* s1, const CString& s2)
  739. {
  740.     return ::RelString(CStr255(s1), (ConstStr255Param)&s2, false, true) >= 0;
  741. }
  742.  
  743. inline Boolean operator>=(const CString& s1, const CString& s2)
  744. {
  745.     return ::RelString((ConstStr255Param)&s1, (ConstStr255Param)&s2, false, true) >= 0;
  746. }
  747.  
  748. inline Boolean operator<=(const CString& s1, const char* s2)
  749. {
  750.     return ::RelString((ConstStr255Param)&s1, CStr255(s2), false, true) <= 0;
  751. }
  752.  
  753. inline Boolean operator<=(const char* s1, const CString& s2)
  754. {
  755.     return ::RelString(CStr255(s1), (ConstStr255Param)&s2, false, true) <= 0;
  756. }
  757.  
  758. inline Boolean operator<=(const CString& s1, const CString& s2)
  759. {
  760.     return ::RelString((ConstStr255Param)&s1, (ConstStr255Param)&s2, false, true) <= 0;
  761. }
  762.  
  763. #endif
  764.