retdec-cpp
resource_arguments.h
Go to the documentation of this file.
1 
8 #ifndef RETDEC_RESOURCE_ARGUMENTS_H
9 #define RETDEC_RESOURCE_ARGUMENTS_H
10 
11 #include <map>
12 #include <memory>
13 #include <string>
14 
15 namespace retdec {
16 
17 class File;
18 
23 private:
25  using Arguments = std::map<std::string, std::string>;
26 
28  using Files = std::map<std::string, std::shared_ptr<File>>;
29 
30 public:
32  using ArgumentIterator = Arguments::const_iterator;
33 
35  using FileIterator = Files::const_iterator;
36 
37 public:
47 
50  ResourceArguments &argument(const std::string &id,
51  const std::string &value);
52  ResourceArguments withArgument(const std::string &id,
53  const std::string &value) const;
54  bool hasArgument(const std::string &id) const;
55  std::string argument(const std::string &id) const;
59 
62  ResourceArguments &file(const std::string &id,
63  const std::shared_ptr<File> &file);
64  ResourceArguments withFile(const std::string &id,
65  const std::shared_ptr<File> &file) const;
66  bool hasFile(const std::string &id) const;
67  std::shared_ptr<File> file(const std::string &id) const;
68  FileIterator filesBegin() const;
69  FileIterator filesEnd() const;
71 
72 protected:
74  Arguments arguments;
75 
77  Files files;
78 };
79 
80 } // namespace retdec
81 
82 #endif
The namespace of the library.
Definition: doxygen.h:8
FileIterator filesBegin() const
Returns an iterator to the beginning of arguments.
Definition: resource_arguments.cpp:136
Base class of arguments for all services.
Definition: resource_arguments.h:22
bool hasArgument(const std::string &id) const
Is an argument of the given ID present?
Definition: resource_arguments.cpp:71
ResourceArguments withArgument(const std::string &id, const std::string &value) const
Returns a copy of the arguments with a differing argument of the given ID.
Definition: resource_arguments.cpp:61
Files::const_iterator FileIterator
Iterator for files.
Definition: resource_arguments.h:35
ArgumentIterator argumentsEnd() const
Returns an iterator past the last argument.
Definition: resource_arguments.cpp:94
ResourceArguments & file(const std::string &id, const std::shared_ptr< File > &file)
Sets the file of the given ID to the given value.
Definition: resource_arguments.cpp:101
ResourceArguments withFile(const std::string &id, const std::shared_ptr< File > &file) const
Returns a copy of the files with a differing file of the given ID.
Definition: resource_arguments.cpp:110
ArgumentIterator argumentsBegin() const
Returns an iterator to the beginning of arguments.
Definition: resource_arguments.cpp:87
~ResourceArguments()
Destructs the arguments.
Files files
Files.
Definition: resource_arguments.h:77
Arguments::const_iterator ArgumentIterator
Iterator for arguments.
Definition: resource_arguments.h:32
bool hasFile(const std::string &id) const
Is a file of the given ID present?
Definition: resource_arguments.cpp:120
ResourceArguments()
Constructs default arguments.
ResourceArguments & argument(const std::string &id, const std::string &value)
Sets the argument of the given ID to the given value.
Definition: resource_arguments.cpp:52
Arguments arguments
Arguments.
Definition: resource_arguments.h:74
ResourceArguments & operator=(const ResourceArguments &other)
Copy-assigns the given arguments.
FileIterator filesEnd() const
Returns an iterator past the last argument.
Definition: resource_arguments.cpp:143