home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / dreamscape / source / Dreamscape / Headers / std / h / stringt < prev    next >
Encoding:
Text File  |  1996-07-17  |  1.7 KB  |  61 lines

  1.  
  2. // std.h.stringt
  3.  
  4. // Dreamscape - C++ class library for RISC OS
  5. // Copyright (c) 1996 Mark Seaborn <mseaborn@argonet.co.uk>
  6. //
  7. // This library is free software; you can redistribute it and/or
  8. // modify it under the terms of the GNU Library General Public
  9. // License as published by the Free Software Foundation; either
  10. // version 2 of the License, or (at your option) any later version.
  11. // See the Dreamscape documentation for more information.
  12.  
  13. #ifndef dreamscape_stringt_H
  14. #define dreamscape_stringt_H
  15.  
  16. #include <string.h>
  17.  
  18. class ostream;
  19. class istream;
  20.  
  21. class String {
  22.   char *data;
  23.   int size;
  24. public:
  25.   String(int size = 0);
  26.   String(const char *data);
  27.   String(const char *data, int size);
  28.   String(const String ©);
  29.   ~String() { delete [] data; }
  30.  
  31.   operator char*() const { return data; }
  32.   String &setsize(int size);
  33.   int length() const { return strlen(data); }
  34.   int getsize() const { return size; }
  35.  
  36.   String &operator=(const char *c);
  37.   String &operator=(char c);
  38.   String &operator+=(const char *c);
  39.   String &operator+=(char c);
  40.   String operator+(const char *c) const;
  41.   String operator+(char c) const;
  42.   char *operator+(int i) const { return data + i; }
  43.  
  44.   friend String operator+(const char *c, const String &s);
  45.   friend String operator+(char c, const String &s);
  46.  
  47.   int operator==(const char *c) const { return !strcmp(data, c); }
  48.   int operator!=(const char *c) const { return strcmp(data, c) ? 1:0; }
  49.  
  50.   friend ostream &operator<<(ostream &stream, const String &string);
  51.   friend istream &operator>>(istream &stream, String &string);
  52. };
  53.  
  54. // Some string utilities
  55. String itostr(int i);
  56. String ftostr(double d);
  57. String ftostr(double d, int dp=2);
  58. int strcmpci(const char *str1, const char *str2);
  59.  
  60. #endif
  61.