1 // 2 // aegis - project change supervisor 3 // Copyright (C) 2004-2006, 2008, 2012 Peter Miller 4 // 5 // This program is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program. If not, see 17 // <http://www.gnu.org/licenses/>. 18 // 19 20 #ifndef LIBAEGIS_INPUT_CROP_H 21 #define LIBAEGIS_INPUT_CROP_H 22 23 #include <libaegis/input.h> 24 25 /** 26 * The input_crop class is used to represent an input which will read 27 * only a portion of the deeper input, from the current position. 28 */ 29 class input_crop: 30 public input_ty 31 { 32 public: 33 /** 34 * The destructor. 35 */ 36 virtual ~input_crop(); 37 38 /** 39 * The constructor. 40 * 41 * @param deeper 42 * the data source for this filter. 43 * @param length 44 * How many bytes of data are in the cropped region. 45 */ 46 input_crop(input &deeper, size_t length); 47 48 // See base class for documentation. 49 nstring name(); 50 51 // See base class for documentation. 52 off_t length(); 53 54 // See base class for documentation. 55 void keepalive(); 56 57 // See base class for documentation. 58 ssize_t read_inner(void *data, size_t nbytes); 59 60 // See base class for documentation. 61 off_t ftell_inner(); 62 63 // See base class for documentation. 64 bool is_remote() const; 65 set_name(const nstring & arg)66 void set_name(const nstring &arg) { name_cache = arg; } 67 68 private: 69 /** 70 * The deeper instance variable is used to remember the data source 71 * for this filter. 72 */ 73 input deeper; 74 75 /** 76 * The maximum instance variable is used to remember how many bytes 77 * of data are in the cropped region. 78 */ 79 size_t maximum; 80 81 /** 82 * The pos instance variable is used to remember where we are up to 83 * in the crop region. 84 */ 85 size_t pos; 86 87 /** 88 * The name_cache instance variable is used to remember the name of 89 * the deeper input stream. 90 */ 91 nstring name_cache; 92 93 /** 94 * The default constructor. Do not use. 95 */ 96 input_crop(); 97 98 /** 99 * The copy constructor. Do not use. 100 */ 101 input_crop(const input_crop &arg); 102 103 /** 104 * The assignment operator. Do not use. 105 */ 106 input_crop &operator=(const input_crop &arg); 107 }; 108 109 #endif // LIBAEGIS_INPUT_CROP_H 110 // vim: set ts=8 sw=4 et : 111