Textractor_test/extensions/extension.h

22 lines
472 B
C
Raw Normal View History

2018-10-12 02:29:11 +08:00
#pragma once
struct InfoForExtension
{
const char* name;
int64_t value;
};
struct SentenceInfo
{
2019-02-09 13:30:38 +08:00
const InfoForExtension* infoArray;
2020-02-28 17:34:07 +08:00
int64_t operator[](std::string_view propertyName)
2018-10-12 02:29:11 +08:00
{
2019-06-29 17:27:39 +08:00
for (auto info = infoArray; info->name; ++info) // nullptr name marks end of info array
if (propertyName == info->name) return info->value;
2019-10-02 17:30:14 +08:00
return *(int*)0xDEAD = 0; // gives better error message than alternatives
2018-10-12 02:29:11 +08:00
}
};
struct SKIP {};
inline void Skip() { throw SKIP(); }