openMSX
Filename.hh
Go to the documentation of this file.
1 #ifndef FILENAME_HH
2 #define FILENAME_HH
3 
4 #include <string>
5 
6 namespace openmsx {
7 
8 class FileContext;
9 
17 class Filename
18 {
19 public:
20  // dummy constructor, to be able to serialize vector<Filename>
21  Filename() = default;
22 
23  explicit Filename(std::string filename);
24  Filename(std::string filename, const FileContext& context);
25 
26  const std::string& getOriginal() const { return originalFilename; }
27  const std::string& getResolved() const { return resolvedFilename; }
28 
34  void updateAfterLoadState();
35 
40  bool empty() const;
41 
46  void setResolved(const std::string& resolved) {
47  resolvedFilename = resolved;
48  }
49 
50  // Do both Filename objects point to the same file?
51  bool operator==(const Filename& other) const {
52  return resolvedFilename == other.resolvedFilename;
53  }
54  bool operator!=(const Filename& other) const {
55  return !(*this == other);
56  }
57 
58  template<typename Archive>
59  void serialize(Archive& ar, unsigned version);
60 
61 private:
62  // non-const because we want this class to be assignable
63  // (to be able to store them in std::vector)
64  std::string originalFilename;
65  std::string resolvedFilename;
66 };
67 
68 } // namespace openmsx
69 
70 #endif
bool operator==(const Filename &other) const
Definition: Filename.hh:51
Filename()=default
void serialize(Archive &ar, unsigned version)
Definition: Filename.cc:45
const std::string & getOriginal() const
Definition: Filename.hh:26
std::unique_ptr< Context > context
Definition: GLContext.cc:9
void updateAfterLoadState()
After a loadstate we prefer to use the exact same file as before savestate.
Definition: Filename.cc:25
bool operator!=(const Filename &other) const
Definition: Filename.hh:54
This class represents a filename.
Definition: Filename.hh:17
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void setResolved(const std::string &resolved)
Change the resolved part of this filename E.g.
Definition: Filename.hh:46
const std::string & getResolved() const
Definition: Filename.hh:27
bool empty() const
Convenience method to test for empty filename.
Definition: Filename.cc:38