Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

RootTbl.C

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta 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 GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Created on Tue Mar  4 10:24:41 PST 1997 by heydon
00020 
00021 // Last modified on Mon Aug  9 17:26:32 EDT 2004 by ken@xorian.net  
00022 //      modified on Sat Feb 12 18:10:12 PST 2000 by mann  
00023 //      modified on Fri Apr  9 16:18:20 PDT 1999 by heydon
00024 
00025 #include <Basics.H>
00026 #include <Table.H>
00027 #include "PkgBuild.H"
00028 #include "RootTbl.H"
00029 
00030 using std::istream;
00031 using std::ostream;
00032 using std::endl;
00033 
00034 typedef Table<PkgBuild,bool>::Iterator RootTblIter;
00035 
00036 void RootTbl::Write(ostream &ofs) const throw (FS::Failure)
00037 {
00038     int tblSize = this->Size();
00039     FS::Write(ofs, (char *)(&tblSize), sizeof(tblSize));
00040     RootTblIter iter(this);
00041     PkgBuild pkg; bool status;
00042     while (iter.Next(/*OUT*/ pkg, /*OUT*/ status)) {
00043         pkg.Write(ofs);
00044         bool8 wstatus = status ? 1 : 0;
00045         FS::Write(ofs, (char *) &wstatus, sizeof_assert(wstatus, 1));
00046     }
00047 }
00048 
00049 void RootTbl::Read(istream &ifs) throw (FS::EndOfFile, FS::Failure)
00050 {
00051     int tblSize;
00052     FS::Read(ifs, (char *)(&tblSize), sizeof(tblSize));
00053     for (int i = 0; i < tblSize; i++) {
00054         PkgBuild pkg(ifs);
00055         bool8 wstatus;
00056         FS::Read(ifs, (char *) &wstatus, sizeof_assert(wstatus, 1));
00057         bool inTbl = this->Put(pkg, wstatus); assert(!inTbl);
00058     }
00059 }
00060 
00061 void RootTbl::Print(ostream &os, int indent,
00062                const Text &tstatus, const Text &fstatus) const throw ()
00063 {
00064     RootTblIter iter(this);
00065     PkgBuild pkg; bool status;
00066     while (iter.Next(/*OUT*/ pkg, /*OUT*/ status)) {
00067         pkg.Print(os, indent);
00068         os << "\t" << (status ? tstatus : fstatus) << endl;
00069     }
00070 }
00071 
00072 

Generated on Mon May 8 00:48:59 2006 for Vesta by  doxygen 1.4.2