Want more features on Pastebin? Sign Up, it's FREE!
Guest

string215.h

By: a guest on Mar 1st, 2013  |  syntax: C++  |  size: 1.62 KB  |  views: 55  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #ifndef STRING215_H_INCLUDED
  2. #define STRING215_H_INCLUDED
  3.  
  4. class string215
  5. {
  6. public:
  7.         // Create a string215 of length zero (null terminator only).
  8.         string215();
  9.         // Create a string215 that is a (deep) copy of another.
  10.         string215(const string215 &other);
  11.         // Destroy a string215 and de-allocate its memory.
  12.         ~string215();
  13.  
  14.         // Return the length of a string215, not counting the null terminator.
  15.         int length() const;
  16.         // Return the character at a given index.  Returns '\0' if the
  17.         // index is out of bounds.
  18.         char getchar(int index) const;
  19.         // Set the character at a given index and return false.
  20.         bool setchar(int index, char newchar);
  21.         // Check whether two strings contain the same characters.
  22.         bool equals(const string215 &other) const;
  23.         // Add a suffix to the end of this string.  Allocates and frees memory.
  24.         void append(const string215 &suffix);
  25.  
  26.         // Return a pointer to the raw character data (not a copy).
  27.         const char *c_str() const;
  28.         // Replace the contents of this string215 with a copy of a C
  29.         // string.  Allocates and frees memory.
  30.         void replace(const char *in_str);
  31.         // Create a string215 that is a (deep) copy of a C string.
  32.         string215(const char *in_str);
  33.  
  34.         // Return the length of a string
  35.         int str_len(const char *str) const;
  36.         // Return true if the two C strings contain the same sequence of characters.
  37.         bool equal_string(const char *first, const char *second) const;
  38.         // Make and return a dynamically-allocated copy of the input C string.
  39.         char *copy_string(const char *input);
  40. private:
  41.         // Pointer to a null-terminated character array storing this
  42.         // object's content.
  43.         char *data;
  44. };
  45.  
  46. #endif
clone this paste RAW Paste Data