Code clean-up

This commit is contained in:
Simon Rozman 2016-10-13 09:01:23 +02:00
parent f51c4dbbec
commit affe7b06a2
7 changed files with 98 additions and 18 deletions

View File

@ -99,49 +99,37 @@ bool ZRColaApp::OnInit()
has_translation_data = true;
} else {
wxFAIL_MSG(wxT("Error reading translation data from ZRCola.zrcdb."));
m_t_db.idxComp .clear();
m_t_db.idxDecomp.clear();
m_t_db.data .clear();
m_t_db.clear();
}
} else if (id == ZRCola::langchar_rec::id) {
dat >> ZRCola::langchar_rec(m_lc_db);
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading language character data from ZRCola.zrcdb."));
m_lc_db.idxChr.clear();
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
m_lc_db.idxLng.clear();
#endif
m_lc_db.data .clear();
m_lc_db.clear();
}
} else if (id == ZRCola::language_rec::id) {
dat >> ZRCola::language_rec(m_lang_db);
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading language character data from ZRCola.zrcdb."));
m_lang_db.idxLng.clear();
m_lang_db.data .clear();
m_lang_db.clear();
}
} else if (id == ZRCola::keyseq_rec::id) {
dat >> ZRCola::keyseq_rec(m_ks_db);
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading key sequences data from ZRCola.zrcdb."));
m_ks_db.idxChr.clear();
m_ks_db.idxKey.clear();
m_ks_db.data .clear();
m_ks_db.clear();
}
} else if (id == ZRCola::character_rec::id) {
dat >> ZRCola::character_rec(m_chr_db);
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading character data from ZRCola.zrcdb."));
m_chr_db.idxChr.clear();
m_chr_db.data .clear();
m_chr_db.clear();
}
} else if (id == ZRCola::chrcat_rec::id) {
dat >> ZRCola::chrcat_rec(m_cc_db);
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading character category data from ZRCola.zrcdb."));
m_cc_db.idxChrCat.clear();
m_cc_db.idxRnk .clear();
m_cc_db.data .clear();
m_cc_db.clear();
}
} else
stdex::idrec::ignore<ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>(dat);

View File

@ -231,6 +231,17 @@ namespace ZRCola {
///
inline character_db() : idxChr(data) {}
///
/// Clears the database
///
inline void clear()
{
idxChr .clear();
idxDsc .clear();
idxDscSub.clear();
data .clear();
}
///
/// Search for characters by description in given categories
///
@ -379,6 +390,16 @@ namespace ZRCola {
/// Constructs the database
///
inline chrcat_db() : idxChrCat(data), idxRnk(data) {}
///
/// Clears the database
///
inline void clear()
{
idxChrCat.clear();
idxRnk .clear();
data .clear();
}
};

View File

@ -439,6 +439,17 @@ namespace ZRCola {
textindex() {}
///
/// Clears the index
///
inline void clear()
{
std::vector< mappair_t<T_idx> >::clear();
keys .clear();
values.clear();
}
///
/// Finds data for given key
///

View File

@ -175,6 +175,18 @@ namespace ZRCola {
#endif
{}
///
/// Clears the database
///
inline void clear()
{
idxChr.clear();
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
idxLng.clear();
#endif
data .clear();
}
///
/// Tests presence of character in the given language
///
@ -248,6 +260,15 @@ namespace ZRCola {
/// Constructs the database
///
inline language_db() : idxLng(data) {}
///
/// Clears the database
///
inline void clear()
{
idxLng.clear();
data .clear();
}
};

View File

@ -170,6 +170,16 @@ namespace ZRCola {
/// Constructs the database
///
inline chrtag_db() : idxChr(data), idxTag(data) {}
///
/// Clears the database
///
inline void clear()
{
idxChr.clear();
idxTag.clear();
data .clear();
}
};
@ -292,6 +302,15 @@ namespace ZRCola {
///
inline tagname_db() : idxName(data) {}
///
/// Clears the database
///
inline void clear()
{
idxName.clear();
data .clear();
}
///
/// Search for tags by names
///

View File

@ -204,6 +204,16 @@ namespace ZRCola {
///
inline translation_db() : idxComp(data), idxDecomp(data) {}
///
/// Clears the database
///
inline void clear()
{
idxComp .clear();
idxDecomp.clear();
data .clear();
}
///
/// Composes string
///

View File

@ -209,6 +209,16 @@ namespace ZRCola {
///
inline keyseq_db() : idxChr(data), idxKey(data) {}
///
/// Clears the database
///
inline void clear()
{
idxChr.clear();
idxKey.clear();
data .clear();
}
///
/// Get text representation of a given key sequence
///