2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: CC_String.h /main/5 1996/08/21 15:48:50 drk $ */
28 #include "dti_cc/types.h"
33 CC_String (const CC_String& x);
35 CC_String (const char *string)
37 int len = strlen(string);
38 f_string = new char[len + 1];
39 *((char *) memcpy(f_string, string, len) + len) = '\0';
47 virtual ~CC_String () { delete f_string; }
49 CC_Boolean isNull() const {
50 return( f_string[0] == '\0' );
53 unsigned int hash() const; /* This returns a hash value
54 * used by the hash funcion
57 size_t length() const { /* Used strlen, so expect string terminated by
58 * \0. The library in RW takes care of non-null
59 * terminated string. I assume this is not
62 return(strlen(f_string));
65 enum caseCompare { exact, ignoreCase };
66 int compareTo(const char *, caseCompare = exact) const;
67 int compareTo(const CC_String &cs, caseCompare CaseSensitive = exact) const
69 return(compareTo((const char *)cs, CaseSensitive));
72 CC_Boolean operator ==(const CC_String &k) const
74 return (compareTo(k) == 0) ? TRUE : FALSE;
77 operator const char *() const { return f_string; }
78 const char *data() const { return f_string; }