SHARE
TWEET

Untitled

a guest Jan 21st, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifndef _OOSTRING_H
  2. #define _OOSTRING_H
  3.  
  4. #include <iostream.h>
  5. // uncomment line below if bool not built-in type
  6. //#include "bool.h"
  7.  
  8. class oostring
  9. {
  10.   public:
  11.  
  12.   // constructors/destructor
  13.  
  14.     oostring( );                         // construct empty string ""
  15.     oostring( const char * s );          // construct from string literal
  16.     oostring( const oostring & str );    // copy constructor
  17.     ~oostring( );                        // destructor
  18.  
  19.  
  20.   // accessors
  21.  
  22.     int      length() const;                   // number of chars
  23.     int      find(const oostring & str) const; // index of first occurrence of str
  24.     int      find(char ch) const;              // index of first occurrence of ch
  25.     oostring substr(int pos, int len) const;   // substring of len chars
  26.                                                // starting at pos
  27.     char * c_str( ) const;                     // explicit conversion to char *
  28.  
  29.  
  30.   // assignment
  31.     const oostring & operator = ( const oostring & str ); // assign str
  32.     const oostring & operator = ( const char * s );       // assign s
  33.     const oostring & operator = ( char ch );              // assign ch
  34.  
  35.  
  36.   // indexing
  37.     char   operator [] ( int k ) const;       // range checked indexing
  38.     char & operator [] ( int k );             // range-checked indexing
  39.  
  40.   // modifiers
  41.     const oostring & operator += ( const oostring & str ); // append str
  42.     const oostring & operator += ( const char * s);        // append s
  43.     const oostring & operator += ( char ch );              // append char
  44.  
  45.     int   converttoint() const;     // ASCII conversion
  46.     long  converttolong() const;    // ASCII conversion
  47.     float converttofloat() const;   // ASCII conversion
  48.     double converttodouble() const; // ASCII conversion
  49.  
  50.   private:
  51.       int   Capacity;                   // capacity of string
  52.       char * CString;                   // storage for characters
  53. };
  54.  
  55. // The following free (non-member) functions operate on strings
  56. //
  57. // I/O functions
  58.  
  59. ostream & operator << ( ostream & os, const oostring & str );
  60. istream & operator >> ( istream & is, oostring & str );
  61. istream & getline( istream & is, oostring & str );
  62.  
  63. // comparison operators:
  64.  
  65. bool operator == ( const oostring & lhs, const oostring & rhs );
  66. bool operator != ( const oostring & lhs, const oostring & rhs );
  67. bool operator <  ( const oostring & lhs, const oostring & rhs );
  68. bool operator <= ( const oostring & lhs, const oostring & rhs );
  69. bool operator >  ( const oostring & lhs, const oostring & rhs );
  70. bool operator >= ( const oostring & lhs, const oostring & rhs );
  71.  
  72. // concatenation operator +
  73.  
  74. oostring operator + ( const oostring & lhs, const oostring & rhs );
  75. oostring operator + ( char ch, const oostring & str );
  76. oostring operator + ( const oostring & str, char ch );
  77.  
  78. #endif
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top