| 35 | #include <tuple> |
| 36 | |
| 37 | class BaseGenerator |
| 38 | { |
| 39 | |
| 40 | public: |
| 41 | int transformXmlToFile(const sdbuscpp::xml::Document& doc, const char* filename) const; |
| 42 | |
| 43 | protected: |
| 44 | enum class StubType |
| 45 | { |
| 46 | ADAPTOR, |
| 47 | PROXY |
| 48 | }; |
| 49 | |
| 50 | constexpr static const char *tab = " "; |
| 51 | |
| 52 | virtual ~BaseGenerator() {} |
| 53 | |
| 54 | /** |
| 55 | * Implementation of public function that is provided by inherited class |
| 56 | * @param doc |
| 57 | * @param filename |
| 58 | * @return |
| 59 | */ |
| 60 | virtual int transformXmlToFileImpl(const sdbuscpp::xml::Document& doc, const char* filename) const = 0; |
| 61 | |
| 62 | |
| 63 | /** |
| 64 | * Write data to file |
| 65 | * @param filename Written file |
| 66 | * @param data Data to write |
| 67 | * @return 0 if ok |
| 68 | */ |
| 69 | int writeToFile(const char* filename, const std::string& data) const; |
| 70 | |
| 71 | /** |
| 72 | * Crete header of file - include guard, includes |
| 73 | * @param filename |
| 74 | * @param stubType |
| 75 | * @return |
| 76 | */ |
| 77 | std::string createHeader(const char* filename, const StubType& stubType) const; |
| 78 | |
| 79 | /** |
| 80 | * Namespaces according to the interface name |
| 81 | * @param ifaceName |
| 82 | * @return tuple: count of namespaces, string with code |
| 83 | */ |
| 84 | std::tuple<unsigned, std::string> generateNamespaces(const std::string& ifaceName) const; |
| 85 | |
| 86 | /** |
| 87 | * Transform arguments into source code |
| 88 | * @param args |
| 89 | * @return tuple: argument names, argument types and names, argument types |
| 90 | */ |
| 91 | std::tuple<std::string, std::string, std::string, std::string> argsToNamesAndTypes(const sdbuscpp::xml::Nodes& args, bool async = false) const; |
| 92 | |
| 93 | /** |
| 94 | * Output arguments to return type |
nothing calls this directly
no outgoing calls
no test coverage detected