6 #include <msp/fs/path.h>
7 #include <msp/time/timestamp.h>
13 Stores data between build runs. This can be used to avoid scanning files again
14 every time builder is run, or to detect outside changes.
16 Data is stored as lists of strings and keyed to target and an arbitrary
17 identifier. Any kind of strings can be stored, even ones that contain
18 unprintable characters or nuls.
23 typedef std::list<std::string> ValueList;
25 typedef std::pair<std::string, std::string> Key;
26 typedef std::map<Key, ValueList> DataMap;
28 SourcePackage &package;
29 Msp::FS::Path filename;
31 Msp::Time::TimeStamp mtime;
35 Cache(SourcePackage &p);
37 /// Sets a key to a single value, replacing any existing values.
38 void set_value(const Target *, const std::string &, const std::string &);
40 /// Appends a value to a key. If the key does not exist, it is created.
41 void append_value(const Target *, const std::string &, const std::string &);
43 /// Sets a key to a list of values, replacing any existing values.
44 void set_values(const Target *, const std::string &, const ValueList &);
46 /** Returns the first value from a key. The key must exist and be
48 const std::string &get_value(const Target *, const std::string &);
50 /// Returns the values from a key. The key must exist.
51 const ValueList &get_values(const Target *, const std::string &);
53 /// Indicates whether a key exists.
54 bool has_key(const Target *, const std::string &);
56 /// Returns the last modification timestamp of the cache.
57 const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
59 /** Loads the cache file and sets the last modification timestamp
63 /** Saves the cache. Does nothing if there is no data to save or nothing