2 FILE : string.hh -- declare String
4 Rehacked by HWN 3/nov/95
6 introduced Class String_handle
10 #error string.hh is obsolete, use std-string.hh
16 // too darn slow with gcc3
25 #include "arithmetic-operator.hh"
26 #include "string-handle.hh"
34 /* partial std::string interface */
36 String (int n, char c);
37 String (char const *source);
38 String (char const *, int n);
39 String (String const &, int pos, ssize n=NPOS);
41 String &operator = (String const &source);
43 void operator += (char const *s) { strh_ += s; }
44 void operator += (String s);
45 char &operator [] (int n);
46 char operator [] (int n) const;
49 char const *c_str () const;
50 char const *data () const;
52 int find (String s, int pos=0) const;
53 int find (char c, int pos=0) const;
54 int find (char const *c, int pos=0) const;
55 int rfind (char c) const;
56 String replace (int pos, int n, String str);
58 String substr (int pos=0, ssize n=NPOS) const;
59 int compare (String const &s) const;
64 String insert (ssize pos, String);
65 ssize copy (char *s, ssize n, ssize pos=0) const;
70 bool null_terminated ();
73 /// return "new"-ed copy of contents
74 Byte *get_copy_byte () const;
75 char *get_copy_str0 () const;
77 Byte const *to_bytes () const;
80 void prepend (String);
82 /// return n leftmost chars
83 String left_string (int n) const;
85 /// return n rightmost chars
86 String right_string (int n) const;
88 /// return a piece starting at index (first char = index_i 0), length n
89 String cut_string (int index_i, int n) const;
91 /// cut out a middle piece, return remainder
92 String nomid_string (int index_i, int n) const;
94 static int compare (String const &s1, const String &s2);
96 /// index of rightmost character C in string
97 int index_last (char c) const;
99 int index (char c) const;
101 /// index of leftmost occurance of STRING
102 int index (String) const;
104 int index_any (String) const;
106 #ifdef STREAM_SUPPORT
107 /// provide Stream output
108 void print_on (ostream &os) const;
111 /// convert to an integer
114 /// convert to a double
115 double to_double () const;
117 String substitute (String find, String replace);
118 String substitute (char find, char replace);
121 #ifdef STRING_UTILS_INLINED
123 #define INLINE inline
125 #include "string.icc"
126 /* we should be resetting INLINE. oh well. */
129 // because char const* also has an operator ==, this is for safety:
130 bool operator == (String s1, char const *s2);
131 bool operator == (char const *s1, String s2);
132 bool operator != (String s1, char const *s2);
133 bool operator != (char const *s1, String s2);
135 IMPLEMENT_ARITHMETIC_OPERATOR (String, +);
136 #ifdef STREAM_SUPPORT
137 ostream &operator << (ostream &os, String d);
143 technically incorrect, but lets keep it here: this is a
144 catch all place for this stuff.
146 #include "international.hh"
149 #endif /* STRING_HH */