libZRCola: Include stdex/idrec.h only after << and >> are overloaded

gcc precompiles templates.  When << and >> operators of our datatypes are
not overloaded at the time <stdex/idrec.h> is #included yet, gcc will
seek/look for currently available << and >> operators when reaching
std::ostream and std::istream templates.

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2022-09-15 12:01:11 +02:00
parent bd01e250b2
commit 9a307978b5
8 changed files with 43 additions and 38 deletions

View File

@ -46,7 +46,7 @@
#include <utility>
#include <vector>
#include <stdex/idrec.h>
#include <zrcola/idrec.h>
#if defined(__WXMSW__)
#include <Msi.h>

View File

@ -20,7 +20,7 @@
#include <wx/intl.h>
#pragma warning(pop)
#include <stdex/idrec.h>
#include <zrcola/idrec.h>
#include <WinStd/Common.h>

View File

@ -7,7 +7,6 @@
#include "common.h"
#include <stdex/idrec.h>
#include <assert.h>
#include <algorithm>
#include <istream>
@ -327,9 +326,6 @@ namespace ZRCola {
};
typedef stdex::idrec::record<character_db, recordid_t, 0x524843 /*"CHR"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> character_rec;
///
/// Character category database
///
@ -486,9 +482,6 @@ namespace ZRCola {
data .clear();
}
};
typedef stdex::idrec::record<chrcat_db, recordid_t, 0x544343 /*"CCT"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> chrcat_rec;
};

View File

@ -7,8 +7,6 @@
#include "common.h"
#include <stdex/idrec.h>
#include <functional>
#pragma warning(push)
@ -164,9 +162,6 @@ namespace ZRCola {
///
void Highlight(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_ std::function<void (hlghtsetid_t set, size_t start, size_t end)> callback) const;
};
typedef stdex::idrec::record<highlight_db, recordid_t, 0x484748 /*"HGH"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> highlight_rec;
};

View File

@ -0,0 +1,27 @@
/*
SPDX-License-Identifier: GPL-3.0-or-later
Copyright © 2015-2022 Amebis
*/
#pragma once
#include "character.h"
#include "highlight.h"
#include "language.h"
#include "tag.h"
#include "translate.h"
#include <stdex/idrec.h>
namespace ZRCola {
typedef stdex::idrec::record<character_db, recordid_t, 0x524843 /*"CHR"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> character_rec;
typedef stdex::idrec::record<chrcat_db, recordid_t, 0x544343 /*"CCT"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> chrcat_rec;
typedef stdex::idrec::record<highlight_db, recordid_t, 0x484748 /*"HGH"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> highlight_rec;
typedef stdex::idrec::record<langchar_db, recordid_t, 0x432d4c /*"L-C"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> langchar_rec;
typedef stdex::idrec::record<language_db, recordid_t, 0x474e4c /*"LNG"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> language_rec;
typedef stdex::idrec::record<chrtag_db, recordid_t, 0x542d43 /*"C-T"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> chrtag_rec;
typedef stdex::idrec::record<tagname_db, recordid_t, 0x4e4754 /*"TGN"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> tagname_rec;
typedef stdex::idrec::record<translation_db, recordid_t, 0x4e5254 /*"TRN"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> translation_rec;
typedef stdex::idrec::record<transet_db, recordid_t, 0x455354 /*"TSE"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> transet_rec;
typedef stdex::idrec::record<transeq_db, recordid_t, 0x515354 /*"TSQ"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> transeq_rec;
}

View File

@ -7,7 +7,6 @@
#include "common.h"
#include <stdex/idrec.h>
#include <istream>
#include <ostream>
#include <vector>
@ -181,9 +180,6 @@ namespace ZRCola {
};
typedef stdex::idrec::record<langchar_db, recordid_t, 0x432d4c /*"L-C"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> langchar_rec;
///
/// Language database
///
@ -282,9 +278,6 @@ namespace ZRCola {
data .clear();
}
};
typedef stdex::idrec::record<language_db, recordid_t, 0x474e4c /*"LNG"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> language_rec;
};

View File

@ -7,7 +7,6 @@
#include "common.h"
#include <stdex/idrec.h>
#include <assert.h>
#include <istream>
#include <ostream>
@ -214,9 +213,6 @@ namespace ZRCola {
};
typedef stdex::idrec::record<chrtag_db, recordid_t, 0x542d43 /*"C-T"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> chrtag_rec;
///
/// Tag name database
///
@ -437,9 +433,6 @@ namespace ZRCola {
///
bool Search(_In_z_ const wchar_t *str, _In_ uint32_t locale, _Inout_ std::map<tagid_t, uint16_t> &hits, _In_opt_ bool (__cdecl *fn_abort)(void *cookie) = NULL, _In_opt_ void *cookie = NULL) const;
};
typedef stdex::idrec::record<tagname_db, recordid_t, 0x4e4754 /*"TGN"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> tagname_rec;
};

View File

@ -8,7 +8,20 @@
#include "common.h"
#include "language.h"
#include <stdex/idrec.h>
namespace ZRCola {
class translation_db;
}
///
/// Reads translation database from a stream
///
/// \param[in ] stream Input stream
/// \param[out] db Translation database
///
/// \returns The stream \p stream
///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::translation_db &db);
#include <algorithm>
#include <istream>
#include <ostream>
@ -320,9 +333,6 @@ namespace ZRCola {
};
typedef stdex::idrec::record<translation_db, recordid_t, 0x4e5254 /*"TRN"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> translation_rec;
///
/// Translation set database
///
@ -436,9 +446,6 @@ namespace ZRCola {
};
typedef stdex::idrec::record<transet_db, recordid_t, 0x455354 /*"TSE"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> transet_rec;
///
/// Translation sequence database
///
@ -608,9 +615,6 @@ namespace ZRCola {
data .clear();
}
};
typedef stdex::idrec::record<transeq_db, recordid_t, 0x515354 /*"TSQ"*/, recordsize_t, ZRCOLA_RECORD_ALIGN> transeq_rec;
};