.xlsx ファイルを解析するクラスと xls ファイルを解析するクラスの 2 つの並列クラスがあります。xlsx パーサーは自分で作成しましたが、別の xls パーサーから継承してクラス モデルに適合させました。ここまでは順調ですね。
どちらのクラスも、db に挿入するための json 配列を作成するために、rapidjson を使用して同じコードを使用することになります。ただし、xlsx 側ではすべてが機能しますが、xls 側では、rapidjson ライブラリを含めて使用すると、次のエラーが発生します。
excelparser/lib/rapidjson/rapidjson.h:370:1: error: template class without a name
xls.cpp からすべてのコードを削除し、xls.h に単純な #include のみを残しても、同じエラーが発生します。
ヘッダー ファイルの行は次のとおりです。
//! UTF-16 encoding.
/*! http://en.wikipedia.org/wiki/UTF-16
\tparam CharType Type for storing 16-bit UTF-16 data. Default is wchar_t. C++11 may use char16_t instead.
\implements Encoding
*/
template<typename CharType = wchar_t>
struct UTF16 { // <-- Line 370
typedef CharType Ch;
static Ch* Encode(Ch* buffer, unsigned codepoint) {
if (codepoint <= 0xFFFF) {
RAPIDJSON_ASSERT(codepoint < 0xD800 || codepoint > 0xDFFF); // Code point itself cannot be surrogate pair
*buffer++ = static_cast<Ch>(codepoint);
}
else {
RAPIDJSON_ASSERT(codepoint <= 0x10FFFF);
unsigned v = codepoint - 0x10000;
*buffer++ = static_cast<Ch>((v >> 10) + 0xD800);
*buffer++ = (v & 0x3FF) + 0xDC00;
}
return buffer;
}
};