| 1 |
|
| 2 |
#ifndef header_gui2cpp |
| 3 |
#define header_gui2cpp |
| 4 |
|
| 5 |
#include <ClanLib/core.h> |
| 6 |
#include <ClanLib/display.h> |
| 7 |
#include <ClanLib/gui.h> |
| 8 |
|
| 9 |
class GUI2CPP |
| 10 |
{ |
| 11 |
//! Construction: |
| 12 |
public: |
| 13 |
GUI2CPP(const std::string &gui_file, const std::string &source_file, const std::string &header_file); |
| 14 |
|
| 15 |
~GUI2CPP(); |
| 16 |
|
| 17 |
//! Attributes: |
| 18 |
public: |
| 19 |
|
| 20 |
//! Operations: |
| 21 |
public: |
| 22 |
//: Load GUI definition file, source file and header file. |
| 23 |
//- <p>Returns false if the loading of any of these files fail.</p> |
| 24 |
bool load(); |
| 25 |
|
| 26 |
//: Convert the contents of source file and header file to include the GUI definition entries. |
| 27 |
bool convert(); |
| 28 |
|
| 29 |
//: Save the source and header files. |
| 30 |
bool save(); |
| 31 |
|
| 32 |
//! Implementation: |
| 33 |
private: |
| 34 |
bool parse_components(const CL_DomElement &componentsElement); |
| 35 |
|
| 36 |
//: Loads a file from disk. |
| 37 |
bool load_file(std::string &file_data, const std::string &filename); |
| 38 |
|
| 39 |
//: Saves a file to disk. |
| 40 |
bool save_file(const std::string &file_data, const std::string &filename); |
| 41 |
|
| 42 |
//: Returns an autogenerated code block. |
| 43 |
std::string find_block(const std::string &file_data, const std::string &block_name); |
| 44 |
|
| 45 |
//: Injects an autogenerated code block into a file data (source or header) string. |
| 46 |
bool inject_block(std::string &file_data, const std::string &block_name, const std::string &block_data); |
| 47 |
|
| 48 |
//: Filenames of the GUI definition file, the source file and the header file. |
| 49 |
std::string gui_file, source_file, header_file; |
| 50 |
|
| 51 |
//: Contents of the source and header files. |
| 52 |
std::string source_data, header_data; |
| 53 |
|
| 54 |
//: Generated header variables code block. |
| 55 |
std::string old_header_variables, new_header_variables; |
| 56 |
|
| 57 |
//: Generated header functions code block. |
| 58 |
std::string old_header_functions, new_header_functions; |
| 59 |
|
| 60 |
//: Generated soruce connections code block. |
| 61 |
std::string old_source_connections, new_source_connections; |
| 62 |
|
| 63 |
//: Contents of the GUI definition file. |
| 64 |
CL_DomDocument gui_document; |
| 65 |
}; |
| 66 |
|
| 67 |
#endif |