Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / utility / ostring.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 /*
24  * $XConsortium: ostring.h /main/3 1996/06/11 17:38:12 cde-hal $
25  *
26  * Copyright (c) 1992 HaL Computer Systems, Inc.  All rights reserved.
27  * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
28  * States.  Use of a copyright notice is precautionary only and does not
29  * imply publication or disclosure.
30  * 
31  * This software contains confidential information and trade secrets of HaL
32  * Computer Systems, Inc.  Use, disclosure, or reproduction is prohibited
33  * without the prior express written permission of HaL Computer Systems, Inc.
34  * 
35  *                         RESTRICTED RIGHTS LEGEND
36  * Use, duplication, or disclosure by the Government is subject to
37  * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
38  * Technical Data and Computer Software clause at DFARS 252.227-7013.
39  *                        HaL Computer Systems, Inc.
40  *                  1315 Dell Avenue, Campbell, CA  95008
41  * 
42  */
43
44
45 #ifndef _ostring_h
46 #define _ostring_h 1
47
48 #include "utility/funcs.h"
49
50 class ostring {
51
52 public:
53    ostring();
54    ostring(const int chunk_size);
55    ostring(char* str, const int str_sz = -1); // -1 means take strlen(str)
56    ostring(const ostring&);
57    virtual ~ostring() { delete v_p; };
58
59 // length of the string
60    int size() const { return v_sz; };                
61 // length of the allocated chunk
62    int alloc_size() const { return v_allo_sz; };     
63
64    ostring& operator +(ostring&);   // merge of two strings
65    int substr(ostring&);            // substring matching
66    
67 // set string to content x
68    Boolean set(const char* x) { return set(x, strlen(x)); };        
69
70    Boolean set(const char* x, int i); // set string to content x with length i
71    Boolean append(const char* x, int l); // append a string x of length i
72    Boolean update(const char* x, int l, int offset); // update a substring x of length i at 'offset'. offset + l should be sz
73      
74 //set alloc_sz to at least new_alloc_sz bytes
75 // pre_zero = true -> zero new space before copy old content over
76    Boolean expand(const int, Boolean pre_zero = false); 
77
78    void reset() { v_sz = 0; };
79    void set_size(const int s) { v_sz = s; v_p[v_sz] = 0; };
80
81    char* get() const { return v_p; }; // get char pointer p
82
83    char* acquire() ; // return what is pointed at by p and reset 
84                     // alloc_sz, sz, and p to 0;
85
86 // append x to this and return this.  
87    ostring* operator+= (ostring* x); 
88
89 // concate all ostring arguments (ostring* 's) to this and return this.
90    ostring* concate_with(...); 
91
92    Boolean string_LS(ostring&) const;
93    Boolean string_EQ(ostring&) const;
94
95    friend ostream& operator <<(ostream&, const ostring&);
96    friend istream& operator >>(istream&, ostring&);
97
98 protected:
99    char *v_p;      // memory chunk pointer
100    int v_sz;       // string size
101    int v_allo_sz;  // allocated memory chunk size
102
103 #ifdef C_API
104    static char* input_buf;
105
106    friend void initialize_MMDB();
107    friend void quit_MMDB();
108 #else
109    static char input_buf[LBUFSIZ];
110 #endif
111 };
112
113 #endif