wip: codegenerator, basic widget present for showing the generated code and specifying
parameters. Some code is also generated but it is not complete yet. minimum still required - field assignments - properly format and escape the query string
This commit is contained in:
parent
daf9536bed
commit
f5145f36ed
19 changed files with 380 additions and 32 deletions
|
|
@ -3,14 +3,19 @@
|
|||
|
||||
#include "Pgsql_declare.h"
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
class LanguageConfig;
|
||||
class QTextStream;
|
||||
|
||||
class CodeBuilder {
|
||||
public:
|
||||
void GenCodeForExecutingQuery(QTextStream &q, const QString &query, const Pgsql::Result &result);
|
||||
void GenReturnStructDefinition(QTextStream &q, const Pgsql::Result &result) const;
|
||||
void setLanguageConfig(std::shared_ptr<const LanguageConfig> config){
|
||||
m_configuration = config;
|
||||
}
|
||||
|
||||
void GenCodeForExecutingQuery(QTextStream &q, const QString &query, const Pgsql::Result &result, QString structname);
|
||||
void GenReturnStructDefinition(QTextStream &q, const Pgsql::Result &result, QString structname) const;
|
||||
|
||||
// Generating code for performing query and going through the result
|
||||
// - Code for executing the query
|
||||
|
|
@ -20,9 +25,21 @@ public:
|
|||
QString columnNameToVariableName(QString column_name) const;
|
||||
QString getTypeName(Oid dbtype) const;
|
||||
private:
|
||||
class ColumnData {
|
||||
public:
|
||||
Oid oid;
|
||||
QString columnName;
|
||||
QString varName; ///< either field of the struct or in loop local var name
|
||||
};
|
||||
using ColumnDataList = std::vector<ColumnData>;
|
||||
|
||||
std::shared_ptr<const LanguageConfig> m_configuration;
|
||||
|
||||
|
||||
void GenFieldAssignments(QTextStream &q, const Pgsql::Result &result);
|
||||
void genFieldDeclaration(QTextStream &q, const QString &format, const QString &column_name, Oid column_type) const;
|
||||
|
||||
ColumnDataList createColumnDataList(const Pgsql::Result &result);
|
||||
};
|
||||
|
||||
#endif // CODEBUILDER_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue