home *** CD-ROM | disk | FTP | other *** search
-
- // std.h.stringt
-
- // Dreamscape - C++ class library for RISC OS
- // Copyright (c) 1996 Mark Seaborn <mseaborn@argonet.co.uk>
- //
- // This library is free software; you can redistribute it and/or
- // modify it under the terms of the GNU Library General Public
- // License as published by the Free Software Foundation; either
- // version 2 of the License, or (at your option) any later version.
- // See the Dreamscape documentation for more information.
-
- #ifndef dreamscape_stringt_H
- #define dreamscape_stringt_H
-
- #include <string.h>
-
- class ostream;
- class istream;
-
- class String {
- char *data;
- int size;
- public:
- String(int size = 0);
- String(const char *data);
- String(const char *data, int size);
- String(const String ©);
- ~String() { delete [] data; }
-
- operator char*() const { return data; }
- String &setsize(int size);
- int length() const { return strlen(data); }
- int getsize() const { return size; }
-
- String &operator=(const char *c);
- String &operator=(char c);
- String &operator+=(const char *c);
- String &operator+=(char c);
- String operator+(const char *c) const;
- String operator+(char c) const;
- char *operator+(int i) const { return data + i; }
-
- friend String operator+(const char *c, const String &s);
- friend String operator+(char c, const String &s);
-
- int operator==(const char *c) const { return !strcmp(data, c); }
- int operator!=(const char *c) const { return strcmp(data, c) ? 1:0; }
-
- friend ostream &operator<<(ostream &stream, const String &string);
- friend istream &operator>>(istream &stream, String &string);
- };
-
- // Some string utilities
- String itostr(int i);
- String ftostr(double d);
- String ftostr(double d, int dp=2);
- int strcmpci(const char *str1, const char *str2);
-
- #endif
-