2 * $XConsortium: OString.hh /main/4 1996/07/06 13:09:08 rws $
4 * Copyright (c) 1992 HaL Computer Systems, Inc. All rights reserved.
5 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
9 * This software contains confidential information and trade secrets of HaL
10 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
11 * without the prior express written permission of HaL Computer Systems, Inc.
13 * RESTRICTED RIGHTS LEGEND
14 * Use, duplication, or disclosure by the Government is subject to
15 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
16 * Technical Data and Computer Software clause at DFARS 252.227-7013.
17 * HaL Computer Systems, Inc.
18 * 1315 Dell Avenue, Campbell, CA 95008
24 class OString : public Hashable
27 enum copy_t { NO_COPY, COPY };
28 OString (const char *s, copy_t copy = COPY)
29 : f_delete_string (FALSE)
32 { if (f_delete_string) delete [] (char *) f_string; }
34 void string (const char *s, copy_t copy = COPY);
35 const char *string() const
36 { return (f_string); }
37 operator const char * () const
38 { return (f_string); }
40 inline u_int hash_code (u_int lower_bound, u_int upper_bound) const;
41 bool equals (const Hashable &s) const
42 { return (strcmp ((OString &) s, f_string) == 0); }
46 bool f_delete_string:1;
50 OString::hash_code (u_int lower_bound, u_int upper_bound) const
52 return (lower_bound + string_hash (f_string) %
53 (upper_bound - lower_bound + 1));