我有两个并行类,一个解析.xlsx文件,另一个解析xls文件。 我自己写了xlsx解析器,但是从另一个xls解析器继承来适合我的类模型。到现在为止还挺好。在C++中没有名称的模板类
这两个类最终使用同一段代码使用rapidjson创建一个json数组插入到数据库。然而,在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;
}
};
我绝对相信,如果我们可以在这个头文件中看到第370行[也许5-10行以上],那么解决这个问题会容易得多... –
对不起。等一下。 –
你走了。添加了失败的位。 –