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
24 * $XConsortium: ostring.h /main/3 1996/06/11 17:38:12 cde-hal $
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.
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.
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
48 #include "utility/funcs.h"
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; };
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; };
64 ostring& operator +(ostring&); // merge of two strings
65 int substr(ostring&); // substring matching
67 // set string to content x
68 Boolean set(const char* x) { return set(x, strlen(x)); };
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
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);
78 void reset() { v_sz = 0; };
79 void set_size(const int s) { v_sz = s; v_p[v_sz] = 0; };
81 char* get() const { return v_p; }; // get char pointer p
83 char* acquire() ; // return what is pointed at by p and reset
84 // alloc_sz, sz, and p to 0;
86 // append x to this and return this.
87 ostring* operator+= (ostring* x);
89 // concate all ostring arguments (ostring* 's) to this and return this.
90 ostring* concate_with(...);
92 Boolean string_LS(ostring&) const;
93 Boolean string_EQ(ostring&) const;
95 friend ostream& operator <<(ostream&, const ostring&);
96 friend istream& operator >>(istream&, ostring&);
99 char *v_p; // memory chunk pointer
100 int v_sz; // string size
101 int v_allo_sz; // allocated memory chunk size
104 static char* input_buf;
106 friend void initialize_MMDB();
107 friend void quit_MMDB();
109 static char input_buf[LBUFSIZ];