1<html><head><base target=k-main></head><body bgcolor=white> 2 3<font face=Times size=3> 4 5These objects are used to pass around untyped data without concern about 6clean-up. They know whether the bytes need to be de-allocated when these 7objects go out of scope. Small amounts of data are stored in the object. 8<P> 9 10Objects of this class are used a lot within Metakit to manipulate its own 11data items generically. The <A HREF="c4_BytesProp.html" >c4_BytesProp</A> class allows storing binary 12data explicitly in a file. If such data files must be portable, then the 13application itself must define a generic format to deal with byte order. 14<P> 15 16How to store an object in binary form in a row (this is not portable): 17<P> 18 19 20<PRE> struct MyStruct { ... }; 21 MyStruct something;</PRE> 22<P> 23 24 25<PRE> <A HREF="c4_BytesProp.html" >c4_BytesProp</A> pData ("Data"); 26 <A HREF="c4_Row.html" >c4_Row</A> row;</PRE> 27<P> 28 29 30<PRE> pData (row) = <A HREF="c4_Bytes.html" >c4_Bytes</A> (&something, sizeof something); 31</PRE> 32<P> 33 34 35 36<hr size=1> 37 38<dl> 39 40 <if !private> 41 <a name="c4_Bytes_Contents___const"><dt> 42 <nobr> 43 const t4_byte* 44 <b>Contents</b> () <i>const</i>; 45 </nobr> 46 <dd> 47 48 49 <font face=Helvetica size=-1>Return a pointer to the contents</font> 50 <p> 51 52 53 <if !private> 54 <a name="c4_Bytes_NONAME"><dt> 55 <nobr> 56 union 57 <b><A HREF='c4_Bytes___NONAME.html'>NONAME</A></b>; 58 </nobr> 59 <dd> 60 61 62 <font face=Helvetica size=-1></font> 63 <p> 64 65 66 <if !private> 67 <a name="c4_Bytes_SetBuffer_int__"><dt> 68 <nobr> 69 t4_byte* 70 <b>SetBuffer</b> (int length_); 71 </nobr> 72 <dd> 73 74 75 <font face=Helvetica size=-1>Define contents as a freshly allocated buffer of given size</font> 76 <p> 77 78 79 <if !private> 80 <a name="c4_Bytes_SetBufferClear_int__"><dt> 81 <nobr> 82 t4_byte* 83 <b>SetBufferClear</b> (int length_); 84 </nobr> 85 <dd> 86 87 88 <font face=Helvetica size=-1>Allocate a buffer and fills its contents with zero bytes</font> 89 <p> 90 91 92 <if !private> 93 <a name="c4_Bytes_Size___const"><dt> 94 <nobr> 95 int 96 <b>Size</b> () <i>const</i>; 97 </nobr> 98 <dd> 99 100 101 <font face=Helvetica size=-1>Return the number of bytes of its contents</font> 102 <p> 103 104 105 <if !private> 106 <a name="c4_Bytes_Swap_c4_Bytes___"><dt> 107 <nobr> 108 void 109 <b>Swap</b> (<A HREF="c4_Bytes.html" >c4_Bytes</A>& bytes_); 110 </nobr> 111 <dd> 112 113 114 <font face=Helvetica size=-1>Swap the contents and ownership of two byte objects</font> 115 <p> 116 117 118 <if !private> 119 <a name="c4_Bytes__LoseCopy___"><dt> 120 <nobr> 121 void 122 <b>_LoseCopy</b> (); 123 </nobr> 124 <dd> 125 126 127 <font face=Helvetica size=-1></font> 128 <p> 129 130 131 <if !private> 132 <a name="c4_Bytes__MakeCopy___"><dt> 133 <nobr> 134 void 135 <b>_MakeCopy</b> (); 136 </nobr> 137 <dd> 138 139 140 <font face=Helvetica size=-1></font> 141 <p> 142 143 144 <if !private> 145 <a name="c4_Bytes__buffer__kMaxBuf_"><dt> 146 <nobr> 147 t4_byte 148 <b>_buffer [kMaxBuf]</b>; 149 </nobr> 150 <dd> 151 152 153 <font face=Helvetica size=-1></font> 154 <p> 155 156 157 <if !private> 158 <a name="c4_Bytes__copy"><dt> 159 <nobr> 160 bool 161 <b>_copy</b>; 162 </nobr> 163 <dd> 164 165 166 <font face=Helvetica size=-1></font> 167 <p> 168 169 170 <if !private> 171 <a name="c4_Bytes__size"><dt> 172 <nobr> 173 int 174 <b>_size</b>; 175 </nobr> 176 <dd> 177 178 179 <font face=Helvetica size=-1></font> 180 <p> 181 182 183 <if !private> 184 <a name="c4_Bytes_c4_Bytes__"><dt> 185 <nobr> 186 187 <b>c4_Bytes</b> (); 188 </nobr> 189 <dd> 190 191 192 <font face=Helvetica size=-1>Construct an empty binary object</font> 193 <p> 194 195 196 <if !private> 197 <a name="c4_Bytes_c4_Bytes_const_"><dt> 198 <nobr> 199 200 <b>c4_Bytes</b> (const <A HREF="c4_Bytes.html" >c4_Bytes</A>& bytes_); 201 </nobr> 202 <dd> 203 204 205 <font face=Helvetica size=-1>Copy constructor </font> 206 <p> 207 208 209 <if !private> 210 <a name="c4_Bytes_c4_Bytes_constint_"><dt> 211 <nobr> 212 213 <b>c4_Bytes</b> (const void* buffer_, int length_); 214 </nobr> 215 <dd> 216 217 218 <font face=Helvetica size=-1>Construct an object with contents, no copy</font> 219 <p> 220 221 222 <if !private> 223 <a name="c4_Bytes_c4_Bytes_constintbool_"><dt> 224 <nobr> 225 226 <b>c4_Bytes</b> (const void* buffer_, int length_, bool makeCopy_); 227 </nobr> 228 <dd> 229 230 231 <font face=Helvetica size=-1>Construct an object with contents, optionally as a copy</font> 232 <p> 233 234 235 <if !private> 236 <a name="c4_Bytes_enum_1"><dt> 237 <nobr> 238 239 <b>enum</b> { kMaxBuf = 16 }; 240 </nobr> 241 <dd> 242 243 244 <font face=Helvetica size=-1></font> 245 <p> 246 247 248 <if !private> 249 <a name="c4_Bytes_operator___const__"><dt> 250 <nobr> 251 <A HREF="c4_Bytes.html" >c4_Bytes</A>& 252 <b>operator= </b> (const <A HREF="c4_Bytes.html" >c4_Bytes</A>& bytes_); 253 </nobr> 254 <dd> 255 256 257 <font face=Helvetica size=-1>Assignment, this may make a private copy of contents</font> 258 <p> 259 260 261 <if !private> 262 <a name="c4_Bytes__c4_Bytes__"><dt> 263 <nobr> 264 265 <b>~c4_Bytes</b> (); 266 </nobr> 267 <dd> 268 269 270 <font face=Helvetica size=-1>Destructor</font> 271 <p> 272 273 274</dl> 275 276<hr size=1 width=50 align=left> 277class 278<b>c4_Bytes</b> 279</font> 280 281</body></html> 282