Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / dti_cc / CC_String.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $XConsortium: CC_String.h /main/5 1996/08/21 15:48:50 drk $ */
24 #ifndef _CC_STRING_H_
25 #define _CC_STRING_H_
26
27 #include <string.h>
28 #include "dti_cc/types.h"
29
30 class CC_String {
31 public: // functions
32
33   CC_String (const CC_String& x);
34
35   CC_String (const char *string)
36   {
37     int len = strlen(string);
38     f_string = new char[len + 1];
39     *((char *) memcpy(f_string, string, len) + len) = '\0';
40   }
41
42   CC_String() 
43   {
44     f_string = NULL;
45   }
46
47   virtual ~CC_String () { delete f_string; }
48
49   CC_Boolean isNull() const { 
50     return( f_string[0] == '\0' );
51   }
52
53   unsigned int hash() const; /* This returns a hash value 
54                               * used by the hash funcion
55                               */
56
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 
60                               * the case here.
61                               */
62     return(strlen(f_string));
63   }
64
65   enum caseCompare { exact, ignoreCase };
66   int  compareTo(const char *, caseCompare = exact) const;
67   int  compareTo(const CC_String &cs, caseCompare CaseSensitive = exact) const
68   { 
69     return(compareTo((const char *)cs, CaseSensitive));
70   }
71  
72   CC_Boolean operator ==(const CC_String &k)  const
73   { 
74     return (compareTo(k) == 0) ? TRUE : FALSE; 
75   }
76
77   operator const char *() const { return f_string; }
78   const char *data() const { return f_string; }
79
80 private: 
81   char *f_string;
82 };
83
84 #endif