00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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( pkg, 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( pkg, status)) {
00067 pkg.Print(os, indent);
00068 os << "\t" << (status ? tstatus : fstatus) << endl;
00069 }
00070 }
00071
00072