retdec-cpp
decompilation.h
Go to the documentation of this file.
1 
8 #ifndef RETDEC_DECOMPILATION_H
9 #define RETDEC_DECOMPILATION_H
10 
11 #include <functional>
12 #include <memory>
13 #include <string>
14 
15 namespace retdec {
16 
17 class File;
18 
19 namespace internal {
20 
21 class Connection;
22 
23 } // namespace internal
24 
29 public:
31  using Callback = std::function<void (const Decompilation &decompilation)>;
32 
37  enum class OnError {
38  Throw,
39  NoThrow
40  };
41 
42 public:
44  Decompilation(const std::string &id,
45  const std::shared_ptr<::retdec::internal::Connection> &conn);
48 
51  std::string getId() const;
52  bool hasFinished();
53  bool hasFinished() const noexcept;
54  bool hasSucceeded();
55  bool hasSucceeded() const noexcept;
56  bool hasFailed();
57  bool hasFailed() const noexcept;
58  int getCompletion();
59  int getCompletion() const noexcept;
60  std::string getError();
61  std::string getError() const;
63 
66  void waitUntilFinished(OnError onError = OnError::Throw);
67  void waitUntilFinished(const Callback &callback,
68  OnError onError = OnError::Throw);
70 
73  std::shared_ptr<File> getOutputHllFile();
74  std::string getOutputHll();
76 
79  Decompilation(const Decompilation &) = delete;
80  Decompilation(Decompilation &&) = delete;
81  Decompilation &operator=(const Decompilation &) = delete;
82  Decompilation &operator=(Decompilation &&) = delete;
84 
85 private:
86  struct Impl;
88  std::unique_ptr<Impl> impl;
89 };
90 
91 } // namespace retdec
92 
93 #endif
Representation of a decompilation.
Definition: decompilation.h:28
The namespace of the library.
Definition: doxygen.h:8
Do not throw DecompilationError when a decompilation fails.
bool hasFinished()
Has the decompilation finished?
Definition: decompilation.cpp:146
Decompilation(const Decompilation &)=delete
bool hasSucceeded()
Has the decompilation succeeded?
Definition: decompilation.cpp:168
Throw DecompilationError when a decompilation fails.
std::function< void(const Decompilation &decompilation)> Callback
Type of a callback for waitUntilFinished().
Definition: decompilation.h:31
STL namespace.
void waitUntilFinished(OnError onError=OnError::Throw)
Waits until the decompilation is finished.
Definition: decompilation.cpp:262
bool hasFailed()
Has the decompilation failed?
Definition: decompilation.cpp:193
int getCompletion()
Returns the completion status (in percentages, 0-100).
Definition: decompilation.cpp:215
OnError
What should the waiting member functions do when a decompilation fails?
Definition: decompilation.h:37
std::string getId() const
Returns the ID of the decompilation.
Definition: decompilation.cpp:137
std::shared_ptr< File > getOutputHllFile()
Returns the output HLL file (C, Python').
Definition: decompilation.cpp:302
std::string getOutputHll()
Returns the content of the output HLL file (C, Python').
Definition: decompilation.cpp:317
std::string getError()
Returns the error message (if any).
Definition: decompilation.cpp:237
~Decompilation()
Destructs the decompilation.
Base class and factory for files.
Definition: file.h:19