1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright 1995 Matthias Ettrich
6 * Copyright 1995-2001 The LyX Team.
8 * This file is Copyright 1996-2001
11 * ======================================================
17 #pragma implementation
21 #include "support/lyxlib.h"
22 #include "support/filetools.h"
23 #include "support/lstrings.h"
32 void DepTable::insert(string const & fi,
37 // not quite sure if this is the correct place for MakeAbsPath
38 string f = MakeAbsPath(fi);
39 if (deplist.find(f) == deplist.end()) {
44 deplist[f] = make_pair(one, two);
49 void DepTable::update()
51 for (DepList::iterator itr = deplist.begin();
54 unsigned long const one = itr->second.second;
55 unsigned long const two = lyx::sum(itr->first);
56 itr->second = make_pair(one, two);
57 if (lyxerr.debugging(Debug::DEPEND)) {
58 lyxerr << "Update dep: " << itr->first << " "
68 bool DepTable::sumchange() const
70 for (DepList::const_iterator cit = deplist.begin();
73 if ((*cit).second.first != cit->second.second) return true;
79 bool DepTable::haschanged(string const & f) const
81 // not quite sure if this is the correct place for MakeAbsPath
82 string fil = MakeAbsPath(f);
83 DepList::const_iterator cit = deplist.find(fil);
84 if (cit != deplist.end()) {
85 if (cit->second.first != cit->second.second
86 && cit->second.second != 0)
93 bool DepTable::extchanged(string const & ext) const
95 for (DepList::const_iterator cit = deplist.begin();
98 if (suffixIs(cit->first, ext)) {
99 if (cit->second.first != cit->second.second)
107 bool DepTable::exist(string const & fil) const
109 DepList::const_iterator cit = deplist.find(fil);
110 if (cit != deplist.end()) return true;
115 void DepTable::remove_files_with_extension(string const & suf)
118 // we want const_iterator (Lgb)
119 for (DepList::iterator cit = deplist.begin();
120 cit != deplist.end(); ++cit) {
121 if (!suffixIs(cit->first, suf))
122 tmp[cit->first] = cit->second;
128 void DepTable::write(string const & f) const
130 ofstream ofs(f.c_str());
131 for (DepList::const_iterator cit = deplist.begin();
132 cit != deplist.end(); ++cit) {
133 if (lyxerr.debugging(Debug::DEPEND)) {
134 lyxerr << "Write dep: "
136 << cit->second.first << " "
137 << cit->second.second << endl;
139 ofs << cit->first << " "
140 << cit->second.first << " "
141 << cit->second.second << endl;
146 void DepTable::read(string const & f)
148 ifstream ifs(f.c_str());
150 unsigned long one = 0;
151 unsigned long two = 0;
152 while(ifs >> nome >> one >> two) {
153 if (lyxerr.debugging(Debug::DEPEND)) {
154 lyxerr << "Read dep: "
159 deplist[nome] = make_pair(one, two);