ZRCola.zrcdb loading added

This commit is contained in:
Simon Rozman 2016-03-01 14:49:32 +01:00
parent 81e88a82e4
commit ce89d26373
6 changed files with 33 additions and 2 deletions

View File

@ -7,7 +7,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\lib\wxExtend\include;..\lib\libZRCola\include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\lib\wxExtend\include;..\lib\stdex\include;..\lib\libZRCola\include</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />

View File

@ -30,5 +30,8 @@
#include <wx/msgdlg.h>
#include <wxex/common.h>
#include <fstream>
#include <string>
#include <vector>
#include <stdex/idrec.h>

View File

@ -42,3 +42,6 @@ public:
/// - false otherwise
virtual bool OnInit();
};
wxDECLARE_APP(ZRColaApp);

View File

@ -30,6 +30,30 @@ wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) :
m_selComposed(0, 0),
wxZRColaComposerPanelBase(parent)
{
wxString sPath(wxPathOnly(wxTheApp->argv[0]));
sPath << wxT("\\..\\data\\ZRCola.zrcdb"); // TODO: Make database file configurable
std::fstream dat((LPCTSTR)sPath, std::ios_base::in | std::ios_base::binary);
if (dat.good()) {
if (stdex::idrec::find<ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>(dat, ZRCOLA_DB_ID, sizeof(ZRCola::recordid_t))) {
ZRCola::recordsize_t size;
dat.read((char*)&size, sizeof(ZRCola::recordsize_t));
if (dat.good()) {
ZRCola::translation_rec r_rec(m_t_db);
if (r_rec.find(dat, size)) {
dat >> r_rec;
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading translation data from ZRCola.zrcdb."));
m_t_db. comp_index.clear();
m_t_db.decomp_index.clear();
m_t_db. data.clear();
}
} else
wxFAIL_MSG(wxT("ZRCola.zrcdb has no translation data."));
}
} else
wxFAIL_MSG(wxT("ZRCola.zrcdb is not a valid ZRCola database."));
}
}

View File

@ -49,6 +49,7 @@ protected:
virtual void OnComposedText(wxCommandEvent& event);
protected:
ZRCola::translation_db m_t_db; ///< Translation database
bool m_progress; ///< Boolean flag to avoid recursive updates of composed and decomposed text controls
ZRCola::mapping_vector m_mapping; ///< Character index mapping vector between composed and decomposed text
std::pair<long, long>

@ -1 +1 @@
Subproject commit 32391e55a37dd6f56577f6b761fbe8589f858095
Subproject commit f5a2b04caa11c846a5414d5c10934723e53aa84b