From c32475c8acb957310a6cb90d4bb0c62dd21c31f7 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 26 Feb 2016 14:27:29 +0100 Subject: [PATCH] Work continues... --- ZRColaCompile/dbsource.cpp | 28 +++++++++++++++++----- ZRColaCompile/dbsource.h | 11 +++++++++ ZRColaCompile/locale/sl.po | 48 +++++++++++++++++++++++++++++++------- ZRColaCompile/main.cpp | 17 ++++++++++++-- ZRColaCompile/stdafx.h | 1 + 5 files changed, 89 insertions(+), 16 deletions(-) diff --git a/ZRColaCompile/dbsource.cpp b/ZRColaCompile/dbsource.cpp index 3929afb..4135b19 100644 --- a/ZRColaCompile/dbsource.cpp +++ b/ZRColaCompile/dbsource.cpp @@ -52,12 +52,12 @@ bool ZRCola::DBSource::Open(const wxString& filename) // Database open and ready. return true; } else { - wxLogMessage(_("Could not open database %s (%x)."), filename.c_str(), hr); + wxLogMessage(wxT("Could not open database %s (0x%x)."), filename.c_str(), hr); LogErrors(); } m_db.Release(); } else - wxLogMessage(_("Creating ADOConnection object failed (%x)."), hr); + wxLogMessage(wxT("Creating ADOConnection object failed (0x%x)."), hr); return false; } @@ -72,7 +72,7 @@ void ZRCola::DBSource::LogErrors() const if (SUCCEEDED(m_db->get_Errors(&errors))) { // Get number of errors. long n = 0; - errors->get_Count(&n); + wxVERIFY(SUCCEEDED(errors->get_Count(&n))); // Iterate the errors. for (long i = 0; i < n; i++) { @@ -80,12 +80,12 @@ void ZRCola::DBSource::LogErrors() const if (SUCCEEDED(errors->get_Item(ATL::CComVariant(i), &err))) { // Write error number and description to the log. long num = 0; - err->get_Number(&num); + wxVERIFY(SUCCEEDED(err->get_Number(&num))); ATL::CComBSTR desc; - err->get_Description(&desc); + wxVERIFY(SUCCEEDED(err->get_Description(&desc))); - wxLogMessage(_("ADO Error 0x%x: %ls"), num, (BSTR)desc); + wxLogMessage(wxT("ADO Error 0x%x: %ls"), num, (BSTR)desc); err->Release(); } @@ -94,3 +94,19 @@ void ZRCola::DBSource::LogErrors() const errors->Release(); } } + + +bool ZRCola::DBSource::SelectCompositions(ATL::CComPtr &rs) const +{ + // Create a new recordset. + if (rs) rs.Release(); + wxCHECK(SUCCEEDED(::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_ALL, IID_IADORecordset, (LPVOID*)&rs)), false); + + // Open it. + if (FAILED(rs->Open(ATL::CComVariant(L"SELECT [komb], [znak] FROM [VRS_ReplChar] WHERE [rang_komb]=1 ORDER BY [komb] ASC"), ATL::CComVariant(m_db), adOpenForwardOnly, adLockReadOnly, adCmdText))) { + LogErrors(); + return false; + } + + return true; +} diff --git a/ZRColaCompile/dbsource.h b/ZRColaCompile/dbsource.h index c2e4c96..29c1e05 100644 --- a/ZRColaCompile/dbsource.h +++ b/ZRColaCompile/dbsource.h @@ -51,6 +51,17 @@ namespace ZRCola { /// void LogErrors() const; + /// + /// Returns ordered decomposed to composed character translations + /// + /// \param[out] rs Recordset with results + /// + /// \returns + /// - true when query succeeds + /// - false otherwise + /// + bool SelectCompositions(ATL::CComPtr &rs) const; + protected: ATL::CComPtr m_db; ///< the database }; diff --git a/ZRColaCompile/locale/sl.po b/ZRColaCompile/locale/sl.po index ebe9acb..b6531e3 100644 --- a/ZRColaCompile/locale/sl.po +++ b/ZRColaCompile/locale/sl.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: ZRColaCompile\n" -"POT-Creation-Date: 2016-02-25 15:12+0100\n" -"PO-Revision-Date: 2016-02-25 15:13+0100\n" +"POT-Creation-Date: 2016-02-26 14:22+0100\n" +"PO-Revision-Date: 2016-02-26 14:23+0100\n" "Last-Translator: Simon Rozman \n" "Language-Team: Amebis, d. o. o., Kamnik \n" "Language: sl_SI\n" @@ -17,21 +17,53 @@ msgstr "" "X-Poedit-KeywordsList: _\n" "X-Poedit-SearchPath-0: .\n" -#: main.cpp:44 +#: main.cpp:51 msgid "Show this help message" msgstr "Pokaži to sporočilo pomoči" -#: main.cpp:45 +#: main.cpp:52 msgid "input file" msgstr "vhodna datoteka" -#: main.cpp:46 +#: main.cpp:53 msgid "output file" msgstr "izhodna datoteka" -#: main.cpp:61 -msgid "Syntax error detected, aborting." -msgstr "Zaznana napaka v sintaksi, prekinjam." +#: main.cpp:75 +msgid "Error initializing COM.\n" +msgstr "Napaka pri vzpostavitvi COM.\n" + +#: main.cpp:82 +#, c-format +msgid "Error opening %s input file.\n" +msgstr "Pri odpiranju vhodne datoteke %s je prišlo do napake.\n" + +#: main.cpp:89 +#, c-format +msgid "Error opening %s output file.\n" +msgstr "Pri odpiranju izhodne datoteke %s je prišlo do napake.\n" + +#: main.cpp:95 +#, c-format +msgid "" +"Error loading compositions from %s input file. Please make sure the input " +"file is ZRCola.zrc compatible.\n" +msgstr "" +"Pri nalaganju sestavljank iz vhodne datoteke %s je prišlo do napake. " +"Preverite, ali je vhodna datoteka res združljiva z ZRCola.zrc.\n" + +#, fuzzy +#~ msgid "Could not open database %s (0x%x)." +#~ msgstr "Ne morem odpreti podatkovne baze %s (%x)." + +#~ msgid "Creating ADOConnection object failed (0x%x)." +#~ msgstr "Stvaritev objekta ADOConnection ni uspela (0x%x)." + +#~ msgid "ADO Error 0x%x: %ls" +#~ msgstr "Napaka ADO 0x%x: %ls" + +#~ msgid "Syntax error detected, aborting." +#~ msgstr "Zaznana napaka v sintaksi, prekinjam." #~ msgid "Help was given, terminating." #~ msgstr "Pomoč prikazana, zaključujem." diff --git a/ZRColaCompile/main.cpp b/ZRColaCompile/main.cpp index 83d50af..f77e55b 100644 --- a/ZRColaCompile/main.cpp +++ b/ZRColaCompile/main.cpp @@ -65,14 +65,14 @@ int _tmain(int argc, _TCHAR *argv[]) break; default: - wxLogMessage(_("Syntax error detected, aborting.")); + wxLogMessage(wxT("Syntax error detected, aborting.")); return -1; } // Initialize COM (CoInitialize). wxCoInitializer initializerOLE(COINIT_MULTITHREADED | COINIT_SPEED_OVER_MEMORY); if (!initializerOLE) { - _ftprintf(stderr, _("Error initializing OLE.\n")); + _ftprintf(stderr, _("Error initializing COM.\n")); return -1; } @@ -83,5 +83,18 @@ int _tmain(int argc, _TCHAR *argv[]) return 1; } + wxFile dst; + const wxString& filenameOut = parser.GetParam(1); + if (!dst.Create(filenameOut, true, wxS_IRUSR | wxS_IWUSR | wxS_IRGRP | wxS_IWGRP | wxS_IROTH)) { + _ftprintf(stderr, _("Error opening %s output file.\n"), filenameOut.fn_str()); + return 1; + } + + ATL::CComPtr rs_comp; + if (!src.SelectCompositions(rs_comp)) { + _ftprintf(stderr, _("Error loading compositions from %s input file. Please make sure the input file is ZRCola.zrc compatible.\n"), filenameIn.fn_str()); + return 1; + } + return 0; } diff --git a/ZRColaCompile/stdafx.h b/ZRColaCompile/stdafx.h index 6245f78..2becbe1 100644 --- a/ZRColaCompile/stdafx.h +++ b/ZRColaCompile/stdafx.h @@ -24,6 +24,7 @@ #include #include +#include #include #include