00001 /*************************************************************************** 00002 * Copyright (C) 2001 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the bit library. * 00006 * * 00007 * The bit library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public License * 00009 * version 3 as published by the Free Software Foundation. * 00010 * * 00011 * The bit library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this software. If not see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 #ifndef BITRECORD_H 00020 #define BITRECORD_H 00021 00022 #include <string> 00023 00024 #include <libxml++/libxml++.h> 00025 00026 #include <bit/recordbase.h> 00027 #include <bit/recordstorage.h> 00028 00034 namespace bit 00035 { 00036 00054 class Record: public RecordBase 00055 { 00056 public: 00057 00059 typedef BitPointer<Record> pointer; 00060 00062 Record( std::string name="", 00063 size_t length_units=BITS, 00064 int offset=0, 00065 size_t offset_units=BITS, 00066 std::string descr="" 00067 ); 00068 00070 static Record::pointer create( std::string name="", 00071 size_t length_units=BITS, 00072 int offset=0, 00073 size_t offset_units=BITS, 00074 std::string descr="" 00075 ); 00076 00078 virtual ~Record(); 00079 00081 virtual size_t length() const; 00082 00083 virtual size_t length(size_t units) const; 00084 00085 virtual const std::string& xml(); 00086 00087 virtual iterator begin(); 00088 00089 virtual iterator end(); 00090 00091 virtual size_t subfields(); 00092 00093 virtual FieldBase::pointer subfield(const std::string& s); 00094 00095 virtual FieldBase::pointer subfield(size_t i); 00096 00097 virtual void add_field(FieldBase::pointer field); 00098 00099 virtual void remove_field(FieldBase::pointer field); 00100 00101 virtual void remove_field(const std::string& name); 00102 00103 virtual FieldBase::pointer clone(); 00104 00105 virtual Container container_type() { return RECORD; } 00106 00107 protected: 00108 00109 RecordStorage m_subfields; 00110 00111 virtual FieldBase::pointer previous_field(FieldBase::pointer current_field) throw (exception::invalid_container_op); 00112 00113 virtual FieldBase::pointer next_field(FieldBase::pointer current_field) throw (exception::invalid_container_op); 00114 }; 00115 00116 } 00117 00118 #endif