Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / object / oid_t.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: oid_t.h /main/6 1996/08/21 15:52:31 drk $
25  *
26  * Copyright (c) 1992 HAL Computer Systems International, Ltd.
27  * All rights reserved.  Unpublished -- rights reserved under
28  * the Copyright Laws of the United States.  USE OF A COPYRIGHT
29  * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
30  * OR DISCLOSURE.
31  * 
32  * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
33  * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.  USE,
34  * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
35  * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
36  * INTERNATIONAL, LTD.
37  * 
38  *                         RESTRICTED RIGHTS LEGEND
39  * Use, duplication, or disclosure by the Government is subject
40  * to the restrictions as set forth in subparagraph (c)(l)(ii)
41  * of the Rights in Technical Data and Computer Software clause
42  * at DFARS 252.227-7013.
43  *
44  *          HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
45  *                  1315 Dell Avenue
46  *                  Campbell, CA  95008
47  * 
48  */
49
50
51 #ifndef _oid_t_h
52 #define _oid_t_h 1
53
54 #ifdef C_API
55 #include "utility/c_stringstream.h"
56 #else
57 #include <sstream>
58 #endif
59
60 #include "utility/funcs.h"
61 #include "utility/buffer.h"
62
63 typedef unsigned short e_code_t;
64 typedef unsigned short c_code_t;
65 typedef mmdb_pos_t i_code_t;
66
67 #define OID_T_SZ (sizeof(i_code_t))
68
69 /*************************************
70 // class code root
71 **************************************/
72
73 class oid_t 
74 {
75 public:
76    oid_t() : v_c_code(0), v_i_code(0), v_e_code(0)  {};
77    oid_t(c_code_t c, i_code_t i) : v_c_code(c), v_i_code(i), v_e_code(0) {};
78    oid_t(const char* source, Boolean ascii_format, Boolean swap_order);
79    oid_t(const oid_t& x) : 
80       v_c_code(x.v_c_code), v_i_code(x.v_i_code), v_e_code(x.v_e_code) {};
81    ~oid_t() {};
82
83 // oid_t equal and less test
84    Boolean eq(const oid_t&) const;
85    Boolean ls(const oid_t&) const;
86    bool  operator==(const oid_t& arg) const { return eq(arg); };
87
88 // class code, oid type and instance code export functions
89    const c_code_t ccode() const { return v_c_code; } ;
90    const i_code_t& icode() const { return v_i_code; } ;
91
92    static unsigned hash(const oid_t&);
93
94 // in/out functions
95    io_status asciiIn(istream&) ;
96    io_status asciiOut(ostream&) const;
97
98    io_status _asciiIn(istream&) ; // a version of asciiIn that does not
99                                   // eat the trailing '\n'
100
101
102    friend ostream& operator<<(ostream&, const oid_t&) ;
103
104 // compacted disk representation In and Out functions
105    int cdr_sizeof();
106    io_status cdrOut(buffer&);
107    io_status cdrIn(buffer&, c_code_t c_code_to_use = 0);
108
109 // out to char strings
110    void to_char_string(char* sink, Boolean swap_order) const;
111
112    friend class root;
113    friend class oid;
114    friend class desc;
115    friend class dl_list_cell;
116    friend class dl_list;
117    friend class compressed_pstring;
118    friend class service_mgr_t;
119    friend class storage_mgr_t;
120    friend class handler;
121    friend class smart_ptr;
122    friend class template_mgr_t;
123
124 protected:
125    void become(const oid_t& x) {
126       v_e_code = x.v_e_code;
127       v_c_code = x.v_c_code;
128       v_i_code = x.v_i_code;
129    };
130    void set_c_code(c_code_t c) {
131       v_c_code = c;
132    }
133    void set_i_code(i_code_t i) {
134       v_i_code = i;
135    }
136    void set_e_code(e_code_t e) {
137       v_e_code = e;
138    }
139
140 protected:
141    c_code_t v_c_code; // class code
142    i_code_t v_i_code; // instance code
143    e_code_t v_e_code; // extended code. Not used within this class.
144                       // for using extra space purpose.
145 };
146
147 typedef oid_t* oid_tPtr;
148
149 #ifdef C_API
150 extern oid_t* ground_ptr;
151 #define ground (*ground_ptr)
152 #else
153 extern oid_t ground;
154 #endif
155
156 #endif
157