1 /* 2 * Seven Kingdoms: Ancient Adversaries 3 * 4 * Copyright 1997,1998 Enlight Software Ltd. 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * 19 */ 20 21 // Filename : OVQUEUE.H 22 // Description : header file of variable length queue 23 24 25 #ifndef __OVQUEUE_H 26 #define __OVQUEUE_H 27 28 class VLenQueue 29 { 30 public: 31 32 char * queue_buf; // data ptr 33 int queue_buf_size; // current buffer capacity 34 int queued_size; // bytes used 35 char * queue_ptr; // 36 37 public: 38 39 VLenQueue(); 40 VLenQueue(int initial_capacity); 41 VLenQueue(VLenQueue &); 42 ~VLenQueue(); 43 44 VLenQueue& operator= (VLenQueue &); 45 void clear(); 46 47 // actually, this can be called 'resize' in terms of stl containers, except 48 // that it specifies _additional_ n elements (not total, like stl functions). 49 // additionally, it returns pointer to the _beginning_ of reserved space 50 char * reserve(int n); 51 void append_queue(VLenQueue &); 52 void swap(VLenQueue &); 53 int length(); 54 55 private: 56 57 // actually, this can be called 'reserve' in terms of stl containers, except 58 // that it specifies _additional_ n elements (not total, like stl functions) 59 void expand(int n); 60 }; 61 62 #endif 63 64