home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / central / PascalString.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  20.7 KB  |  754 lines

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