Disk ARchive 2.4.2
|
00001 /*********************************************************************/ 00002 // dar - disk archive - a backup/restoration program 00003 // Copyright (C) 2002-2052 Denis Corbin 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 // 00019 // to contact the author : http://dar.linux.free.fr/email.html 00020 /*********************************************************************/ 00021 // $Id: tlv.hpp,v 1.2 2009/12/18 10:10:21 edrusb Rel $ 00022 // 00023 /*********************************************************************/ 00024 00028 00029 #ifndef TLV_HPP 00030 #define TLV_HPP 00031 00032 #include "memory_file.hpp" 00033 #include "storage.hpp" 00034 00035 namespace libdar 00036 { 00039 00041 00044 class tlv 00045 { 00046 public: 00047 00048 // constructors & Co. 00049 00050 tlv() { type = 0; value = NULL; }; 00051 tlv(generic_file & f) { init(f); }; 00052 00053 00054 // methods (read / write tlv datastructure to file) 00055 00056 void read(generic_file & f); //< same as the constructor but on an existing object 00057 void write(generic_file & f) const; //< dumps the tlv contents to file 00058 00059 // methods to fill the tlv object 00060 00061 U_16 get_type() const { return type; }; //< get the TLV type 00062 void set_type(U_16 val) { type = val; }; //< set the TLV type 00063 void set_contents(const memory_file & contents); //< the generic_file object is provided to dump data to the tlv object 00064 void get_contents(memory_file & contents) const; //< the generic_file object is provided to read data from the tlv object 00065 00066 private: 00067 U_16 type; 00068 storage *value; 00069 00070 void init(generic_file & f); 00071 }; 00072 00074 00075 } // end of namespace 00076 00077 #endif 00078 00079