public static void Main() { _parser = new HeaderParser() { FileName = "DB2Structure.h" }; _parser.Parse(); using (var hotfixesSql = new StreamWriter($"{DateTime.Now:yyyy_MM_dd}_00_hotfixes.sql")) using (var hotfixesCpp = new StreamWriter($"{DateTime.Now:yyyy_MM_dd}_HotfixDatabase.cpp")) using (var hotfixesH = new StreamWriter($"{DateTime.Now:yyyy_MM_dd}_HotfixDatabase.h")) using (var infoH = new StreamWriter($"{DateTime.Now:yyyy_MM_dd}_DB2LoadInfo.h")) { WriteLicense(hotfixesCpp); hotfixesCpp.WriteLine("#include \"HotfixDatabase.h\""); hotfixesCpp.WriteLine("#include \"MySQLPreparedStatement.h\""); hotfixesCpp.WriteLine(); hotfixesCpp.WriteLine("// Force max id statements to appear exactly right after normal data fetch statement"); hotfixesCpp.WriteLine("#define PREPARE_MAX_ID_STMT(stmtBase, sql, con) \\"); hotfixesCpp.WriteLine(" static_assert(stmtBase + HOTFIX_MAX_ID_STMT_OFFSET == stmtBase##_MAX_ID, \"Invalid prepared statement index for \" #stmtBase \"_MAX_ID\"); \\"); hotfixesCpp.WriteLine(" PrepareStatement(stmtBase##_MAX_ID, sql, con);"); hotfixesCpp.WriteLine(); hotfixesCpp.WriteLine("// Force locale statements to be right after max id fetch statement"); hotfixesCpp.WriteLine("#define PREPARE_LOCALE_STMT(stmtBase, sql, con) \\"); hotfixesCpp.WriteLine(" static_assert(stmtBase + HOTFIX_LOCALE_STMT_OFFSET == stmtBase##_LOCALE, \"Invalid prepared statement index for \" #stmtBase \"_LOCALE\"); \\"); hotfixesCpp.WriteLine(" PrepareStatement(stmtBase##_LOCALE, sql, con);"); hotfixesCpp.WriteLine(); hotfixesCpp.WriteLine("void HotfixDatabaseConnection::DoPrepareStatements()"); hotfixesCpp.WriteLine("{"); hotfixesCpp.WriteLine(" if (!m_reconnecting)"); hotfixesCpp.WriteLine(" m_stmts.resize(MAX_HOTFIXDATABASE_STATEMENTS);"); WriteLicense(hotfixesH); hotfixesH.WriteLine("#ifndef _HOTFIXDATABASE_H"); hotfixesH.WriteLine("#define _HOTFIXDATABASE_H"); hotfixesH.WriteLine(""); hotfixesH.WriteLine("#include \"MySQLConnection.h\""); hotfixesH.WriteLine(""); hotfixesH.WriteLine("enum HotfixDatabaseStatements : uint32"); hotfixesH.WriteLine("{"); hotfixesH.WriteLine(" /* Naming standard for defines:"); hotfixesH.WriteLine(" {DB}_{SEL/INS/UPD/DEL/REP}_{Summary of data changed}"); hotfixesH.WriteLine(" When updating more than one field, consider looking at the calling function"); hotfixesH.WriteLine(" name for a suiting suffix."); hotfixesH.WriteLine(" */"); WriteLicense(infoH); infoH.WriteLine("#ifndef DB2LoadInfo_h__"); infoH.WriteLine("#define DB2LoadInfo_h__"); infoH.WriteLine(""); infoH.WriteLine("#include \"DB2DatabaseLoader.h\""); infoH.WriteLine("#include \"DB2Metadata.h\""); infoH.WriteLine(""); foreach (var structure in _parser.Structures) { DumpStructure(hotfixesSql, hotfixesCpp, hotfixesH, infoH, structure); } hotfixesCpp.WriteLine("}"); hotfixesCpp.WriteLine(); hotfixesCpp.WriteLine("HotfixDatabaseConnection::HotfixDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo)"); hotfixesCpp.WriteLine("{"); hotfixesCpp.WriteLine("}"); hotfixesCpp.WriteLine(); hotfixesCpp.WriteLine("HotfixDatabaseConnection::HotfixDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo)"); hotfixesCpp.WriteLine("{"); hotfixesCpp.WriteLine("}"); hotfixesCpp.WriteLine(); hotfixesCpp.WriteLine("HotfixDatabaseConnection::~HotfixDatabaseConnection()"); hotfixesCpp.WriteLine("{"); hotfixesCpp.WriteLine("}"); hotfixesH.WriteLine(""); hotfixesH.WriteLine(" MAX_HOTFIXDATABASE_STATEMENTS"); hotfixesH.WriteLine("};"); hotfixesH.WriteLine(""); hotfixesH.WriteLine("uint32 constexpr HOTFIX_MAX_ID_STMT_OFFSET = 1;"); hotfixesH.WriteLine("uint32 constexpr HOTFIX_LOCALE_STMT_OFFSET = 2;"); hotfixesH.WriteLine(""); hotfixesH.WriteLine("class TC_DATABASE_API HotfixDatabaseConnection : public MySQLConnection"); hotfixesH.WriteLine("{"); hotfixesH.WriteLine("public:"); hotfixesH.WriteLine(" typedef HotfixDatabaseStatements Statements;"); hotfixesH.WriteLine(""); hotfixesH.WriteLine(" //- Constructors for sync and async connections"); hotfixesH.WriteLine(" HotfixDatabaseConnection(MySQLConnectionInfo& connInfo);"); hotfixesH.WriteLine(" HotfixDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo);"); hotfixesH.WriteLine(" ~HotfixDatabaseConnection();"); hotfixesH.WriteLine(""); hotfixesH.WriteLine(" //- Loads database type specific prepared statements"); hotfixesH.WriteLine(" void DoPrepareStatements() override;"); hotfixesH.WriteLine("};"); hotfixesH.WriteLine(""); hotfixesH.WriteLine("#endif"); infoH.WriteLine("#endif // DB2LoadInfo_h__"); } }
public static void Main(string[] args) { _parser = new HeaderParser() { FileName = "DB2Structure.h" }; _parser.Parse(); using (var output = new StreamWriter($"{DateTime.Now.ToString("yyyy_MM_dd")}_00_hotfixes.sql")) using (var hotfixesCpp = new StreamWriter($"{DateTime.Now.ToString("yyyy_MM_dd")}_HotfixDatabase.cpp")) using (var hotfixesH = new StreamWriter($"{DateTime.Now.ToString("yyyy_MM_dd")}_HotfixDatabase.h")) { WriteLicense(hotfixesCpp); hotfixesCpp.WriteLine("#include \"HotfixDatabase.h\""); hotfixesCpp.WriteLine(); hotfixesCpp.WriteLine("// Force locale statments to appear exactly in locale declaration order, right after normal data fetch statement"); hotfixesCpp.WriteLine("#define PREPARE_LOCALE_STMT(stmtBase, sql, con) \\"); hotfixesCpp.WriteLine(" static_assert(stmtBase + 1 == stmtBase##_LOCALE, \"Invalid prepared statement index for \" #stmtBase \"_LOCALE\"); \\"); hotfixesCpp.WriteLine(" PrepareStatement(stmtBase##_LOCALE, sql, con);"); hotfixesCpp.WriteLine(); hotfixesCpp.WriteLine("void HotfixDatabaseConnection::DoPrepareStatements()"); hotfixesCpp.WriteLine("{"); hotfixesCpp.WriteLine(" if (!m_reconnecting)"); hotfixesCpp.WriteLine(" m_stmts.resize(MAX_HOTFIXDATABASE_STATEMENTS);"); WriteLicense(hotfixesH); hotfixesH.WriteLine("#ifndef _HOTFIXDATABASE_H"); hotfixesH.WriteLine("#define _HOTFIXDATABASE_H"); hotfixesH.WriteLine(""); hotfixesH.WriteLine("#include \"DatabaseWorkerPool.h\""); hotfixesH.WriteLine("#include \"MySQLConnection.h\""); hotfixesH.WriteLine(""); hotfixesH.WriteLine("enum HotfixDatabaseStatements"); hotfixesH.WriteLine("{"); hotfixesH.WriteLine(" /* Naming standard for defines:"); hotfixesH.WriteLine(" {DB}_{SEL/INS/UPD/DEL/REP}_{Summary of data changed}"); hotfixesH.WriteLine(" When updating more than one field, consider looking at the calling function"); hotfixesH.WriteLine(" name for a suiting suffix."); hotfixesH.WriteLine(" */"); foreach (var structure in _parser.Structures) { DumpStructure(output, hotfixesCpp, hotfixesH, structure); } hotfixesCpp.WriteLine("}"); hotfixesH.WriteLine(""); hotfixesH.WriteLine(" MAX_HOTFIXDATABASE_STATEMENTS"); hotfixesH.WriteLine("};"); hotfixesH.WriteLine(""); hotfixesH.WriteLine("class TC_DATABASE_API HotfixDatabaseConnection : public MySQLConnection"); hotfixesH.WriteLine("{"); hotfixesH.WriteLine("public:"); hotfixesH.WriteLine(" typedef HotfixDatabaseStatements Statements;"); hotfixesH.WriteLine(""); hotfixesH.WriteLine(" //- Constructors for sync and async connections"); hotfixesH.WriteLine(" HotfixDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo) { }"); hotfixesH.WriteLine(" HotfixDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { }"); hotfixesH.WriteLine(""); hotfixesH.WriteLine(" //- Loads database type specific prepared statements"); hotfixesH.WriteLine(" void DoPrepareStatements() override;"); hotfixesH.WriteLine("};"); hotfixesH.WriteLine(""); hotfixesH.WriteLine("typedef DatabaseWorkerPool<HotfixDatabaseConnection> HotfixDatabaseWorkerPool;"); hotfixesH.WriteLine(""); hotfixesH.WriteLine("#endif"); } }
public static void Main(string[] args) { _parser = new HeaderParser("DB2Structure.h"); _parser.Parse(); using (var output = new StreamWriter(String.Format("{0}_00_hotfixes.sql", DateTime.Now.ToString("yyyy_MM_dd")))) using (var hotfixesCpp = new StreamWriter(String.Format("{0}_HotfixDatabase.cpp", DateTime.Now.ToString("yyyy_MM_dd")))) using (var hotfixesH = new StreamWriter(String.Format("{0}_HotfixDatabase.h", DateTime.Now.ToString("yyyy_MM_dd")))) { WriteLicense(hotfixesCpp); hotfixesCpp.WriteLine("#include \"HotfixDatabase.h\""); hotfixesCpp.WriteLine(); hotfixesCpp.WriteLine("// Force locale statments to appear exactly in locale declaration order, right after normal data fetch statement"); hotfixesCpp.WriteLine("#define PREPARE_LOCALE_STMT(stmtBase, sql, con) \\"); hotfixesCpp.WriteLine(" static_assert(stmtBase + 1 == stmtBase##_LOCALE, \"Invalid prepared statement index for \" #stmtBase \"_LOCALE\"); \\"); hotfixesCpp.WriteLine(" PrepareStatement(stmtBase##_LOCALE, sql, con);"); hotfixesCpp.WriteLine(); hotfixesCpp.WriteLine("void HotfixDatabaseConnection::DoPrepareStatements()"); hotfixesCpp.WriteLine("{"); hotfixesCpp.WriteLine(" if (!m_reconnecting)"); hotfixesCpp.WriteLine(" m_stmts.resize(MAX_HOTFIXDATABASE_STATEMENTS);"); WriteLicense(hotfixesH); hotfixesH.WriteLine("#ifndef _HOTFIXDATABASE_H"); hotfixesH.WriteLine("#define _HOTFIXDATABASE_H"); hotfixesH.WriteLine(""); hotfixesH.WriteLine("#include \"DatabaseWorkerPool.h\""); hotfixesH.WriteLine("#include \"MySQLConnection.h\""); hotfixesH.WriteLine(""); hotfixesH.WriteLine("class HotfixDatabaseConnection : public MySQLConnection"); hotfixesH.WriteLine("{"); hotfixesH.WriteLine(" public:"); hotfixesH.WriteLine(" //- Constructors for sync and async connections"); hotfixesH.WriteLine(" HotfixDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo) { }"); hotfixesH.WriteLine(" HotfixDatabaseConnection(ProducerConsumerQueue<SQLOperation*>* q, MySQLConnectionInfo& connInfo) : MySQLConnection(q, connInfo) { }"); hotfixesH.WriteLine(""); hotfixesH.WriteLine(" //- Loads database type specific prepared statements"); hotfixesH.WriteLine(" void DoPrepareStatements() override;"); hotfixesH.WriteLine("};"); hotfixesH.WriteLine(""); hotfixesH.WriteLine("typedef DatabaseWorkerPool<HotfixDatabaseConnection> HotfixDatabaseWorkerPool;"); hotfixesH.WriteLine(""); hotfixesH.WriteLine("enum HotfixDatabaseStatements"); hotfixesH.WriteLine("{"); hotfixesH.WriteLine(" /* Naming standard for defines:"); hotfixesH.WriteLine(" {DB}_{SEL/INS/UPD/DEL/REP}_{Summary of data changed}"); hotfixesH.WriteLine(" When updating more than one field, consider looking at the calling function"); hotfixesH.WriteLine(" name for a suiting suffix."); hotfixesH.WriteLine(" */"); foreach (var structure in _parser.Structures) DumpStructure(output, hotfixesCpp, hotfixesH, structure); hotfixesCpp.WriteLine("}"); hotfixesH.WriteLine(); hotfixesH.WriteLine(" MAX_HOTFIXDATABASE_STATEMENTS"); hotfixesH.WriteLine("};"); hotfixesH.WriteLine(); hotfixesH.WriteLine("#endif"); } }