#include "insrcdata.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
static unsigned const PERSON_TABLE_COUNT = 4;
static const person_t PERSON_TABLE[PERSON_TABLE_COUNT] = {
{"Marie Curie", true, 1.0, 1, 0, 0, },
{"Pierre Curie", false, 2.1, 0, 0, 0, },
{"Irène Joliot-Curie", true, 3.2, 3, 2, 1, },
{"Frédéric Joliot-Curie", false, 2.1, 2, 0, 0, },
};
const person_t* person_next(person_iter_t* idx) { return idx->ptr<idx->end ? &PERSON_TABLE[*idx->ptr++] : NULL; }
static unsigned const PERSON_SCORE_INDEX_COUNT = 4;
static uint8_t PERSON_SCORE_INDEX [PERSON_SCORE_INDEX_COUNT] = {
0, 1, 3, 2,
};
const person_t* person_from_persons(persons_t label) {
return &PERSON_TABLE[label];
}
persons_t person_persons(const person_t *s) {
return (persons_t)(s-PERSON_TABLE);
}
const strencoding_t STRENCODING_TABLE[STRENCODING_TABLE_COUNT] = {
{"𝒾ň𝗌яčḓẚᵵᶏ : 𝔢ᶆḃ℮𝚍 ᶌ𝖔ừᵳ ⅆằƫⱥ", },
{"hello", },
{"κόσμε", },
{"いろはにほへとちりぬるを", },
{"éventuellement validé", },
{"Да, но фальшивый экземпляр", },
};
const strencoding_t* strencoding_next(strencoding_iter_t* idx) { return idx->ptr<idx->end ? &STRENCODING_TABLE[*idx->ptr++] : NULL; }
static unsigned const STRENCODING_TEXT_INDEX_COUNT = 6;
static uint8_t STRENCODING_TEXT_INDEX [STRENCODING_TEXT_INDEX_COUNT] = {
1, 4, 2, 5, 3, 0,
};
static unsigned const LETTERCASE_TABLE_COUNT = 3;
static const lettercase_t LETTERCASE_TABLE[LETTERCASE_TABLE_COUNT] = {
{"Capitalised case", make_capitalize, &POINT_ZERO, },
{"Upper case", make_upper, &POINT_ONE, },
{"Lower case", make_lower, &POINT_ONE, },
};
const lettercase_t* lettercase_next(lettercase_iter_t* idx) { return idx->ptr<idx->end ? &LETTERCASE_TABLE[*idx->ptr++] : NULL; }
const lettercase_t* lettercase_from_lettercases(lettercases_t label) {
return &LETTERCASE_TABLE[label];
}
lettercases_t lettercase_lettercases(const lettercase_t *s) {
return (lettercases_t)(s-LETTERCASE_TABLE);
}
const wikidata_t WIKIDATA_TABLE[WIKIDATA_TABLE_COUNT] = {
{7186, 0, },
{8185162, 6, },
{150989, 3, },
};
const wikidata_t* wikidata_next(wikidata_iter_t* idx) { return idx->ptr<idx->end ? &WIKIDATA_TABLE[*idx->ptr++] : NULL; }
static unsigned const WIKIDATA_OBJECT_INDEX_COUNT = 3;
static uint8_t WIKIDATA_OBJECT_INDEX [WIKIDATA_OBJECT_INDEX_COUNT] = {
0, 2, 1,
};
const congress_t CONGRESS_TABLE[CONGRESS_TABLE_COUNT] = {
{"n2009011553", 1, },
{"sh85148650", 7, },
{"n80159913", 4, },
{"n79006404", 0, },
};
const congress_t* congress_next(congress_iter_t* idx) { return idx->ptr<idx->end ? &CONGRESS_TABLE[*idx->ptr++] : NULL; }
static unsigned const CONGRESS_OBJECT_INDEX_COUNT = 3;
static uint8_t CONGRESS_OBJECT_INDEX [CONGRESS_OBJECT_INDEX_COUNT] = {
0, 2, 1,
};
person_iter_t person_score_range( double start, double stop) {
uint8_t* lo = PERSON_SCORE_INDEX;
uint8_t* hi = PERSON_SCORE_INDEX + PERSON_SCORE_INDEX_COUNT;
while( lo < hi ){
uint8_t* mid = lo + ( hi-lo)/2;
if( start>PERSON_TABLE[*mid].score_ ){
lo = mid + 1;
} else {
hi = mid;
}
}
uint8_t* begin = lo;
hi = PERSON_SCORE_INDEX + PERSON_SCORE_INDEX_COUNT;
while( lo < hi ){
uint8_t* mid = lo + ( hi-lo)/2;
if( stop<PERSON_TABLE[*mid].score_ ){
hi = mid;
} else {
lo = mid + 1;
}
}
person_iter_t res = { begin, lo };
return res;
}
const person_t* person_spouse(const person_t* s) { return &PERSON_TABLE[s->spouse_];}
bool person_father(const person_t* s, const person_t** ptr) {
if( s->father_) {
*ptr = &PERSON_TABLE[s->father_-1];
return true;
}
return false;
}
bool person_mother(const person_t* s, const person_t** ptr) {
if( s->mother_) {
*ptr = &PERSON_TABLE[s->mother_-1];
return true;
}
return false;
}
wikidata_iter_t person_wdata(const person_t* s) {
long cons = s - PERSON_TABLE;
uint8_t* lo = WIKIDATA_OBJECT_INDEX;
uint8_t* hi = WIKIDATA_OBJECT_INDEX + WIKIDATA_OBJECT_INDEX_COUNT;
while( lo < hi ){
uint8_t* mid = lo + ( hi-lo)/2;
if ( cons > WIKIDATA_TABLE[*mid].object_ ) {
lo = mid + 1;
} else {
hi = mid;
}
}
uint8_t* begin = lo;
hi = WIKIDATA_OBJECT_INDEX + WIKIDATA_OBJECT_INDEX_COUNT;
while( lo < hi ){
uint8_t* mid = lo + ( hi-lo)/2;
if( cons < WIKIDATA_TABLE[*mid].object_ ) {
hi = mid;
} else {
lo = mid + 1;
}
}
wikidata_iter_t res = { begin, lo };
return res;
}
congress_iter_t person_congress(const person_t* s) {
long cons = s - PERSON_TABLE + 1;
uint8_t* lo = CONGRESS_OBJECT_INDEX;
uint8_t* hi = CONGRESS_OBJECT_INDEX + CONGRESS_OBJECT_INDEX_COUNT;
while( lo < hi ){
uint8_t* mid = lo + ( hi-lo)/2;
if ( cons > CONGRESS_TABLE[*mid].object_ ) {
lo = mid + 1;
} else {
hi = mid;
}
}
uint8_t* begin = lo;
hi = CONGRESS_OBJECT_INDEX + CONGRESS_OBJECT_INDEX_COUNT;
while( lo < hi ){
uint8_t* mid = lo + ( hi-lo)/2;
if( cons < CONGRESS_TABLE[*mid].object_ ) {
hi = mid;
} else {
lo = mid + 1;
}
}
congress_iter_t res = { begin, lo };
return res;
}
strencoding_iter_t strencoding_text_range( const char* start, const char* stop) {
uint8_t* lo = STRENCODING_TEXT_INDEX;
uint8_t* hi = STRENCODING_TEXT_INDEX + STRENCODING_TEXT_INDEX_COUNT;
while( lo < hi ){
uint8_t* mid = lo + ( hi-lo)/2;
if( strcmp(start,STRENCODING_TABLE[*mid].text_ )>0 ){
lo = mid + 1;
} else {
hi = mid;
}
}
uint8_t* begin = lo;
hi = STRENCODING_TEXT_INDEX + STRENCODING_TEXT_INDEX_COUNT;
while( lo < hi ){
uint8_t* mid = lo + ( hi-lo)/2;
if( strcmp(stop,STRENCODING_TABLE[*mid].text_ )<0 ){
hi = mid;
} else {
lo = mid + 1;
}
}
strencoding_iter_t res = { begin, lo };
return res;
}
wikidata_iter_t lettercase_wdata2(const lettercase_t* s) {
long cons = s - LETTERCASE_TABLE + 4;
uint8_t* lo = WIKIDATA_OBJECT_INDEX;
uint8_t* hi = WIKIDATA_OBJECT_INDEX + WIKIDATA_OBJECT_INDEX_COUNT;
while( lo < hi ){
uint8_t* mid = lo + ( hi-lo)/2;
if ( cons > WIKIDATA_TABLE[*mid].object_ ) {
lo = mid + 1;
} else {
hi = mid;
}
}
uint8_t* begin = lo;
hi = WIKIDATA_OBJECT_INDEX + WIKIDATA_OBJECT_INDEX_COUNT;
while( lo < hi ){
uint8_t* mid = lo + ( hi-lo)/2;
if( cons < WIKIDATA_TABLE[*mid].object_ ) {
hi = mid;
} else {
lo = mid + 1;
}
}
wikidata_iter_t res = { begin, lo };
return res;
}
congress_iter_t lettercase_congress(const lettercase_t* s) {
long cons = s - LETTERCASE_TABLE + 5;
uint8_t* lo = CONGRESS_OBJECT_INDEX;
uint8_t* hi = CONGRESS_OBJECT_INDEX + CONGRESS_OBJECT_INDEX_COUNT;
while( lo < hi ){
uint8_t* mid = lo + ( hi-lo)/2;
if ( cons > CONGRESS_TABLE[*mid].object_ ) {
lo = mid + 1;
} else {
hi = mid;
}
}
uint8_t* begin = lo;
hi = CONGRESS_OBJECT_INDEX + CONGRESS_OBJECT_INDEX_COUNT;
while( lo < hi ){
uint8_t* mid = lo + ( hi-lo)/2;
if( cons < CONGRESS_TABLE[*mid].object_ ) {
hi = mid;
} else {
lo = mid + 1;
}
}
congress_iter_t res = { begin, lo };
return res;
}
wikidata_object_t wikidata_object(const wikidata_t* s){
int v = s->object_ ;
if(v<=3) {return (wikidata_object_t){.type=WIKIDATA_PERSON, .person=PERSON_TABLE+v-0}; }
if(v<=6) {return (wikidata_object_t){.type=WIKIDATA_LETTERCASE, .lettercase=LETTERCASE_TABLE+v-4}; }
perror("insrcdata variant index overflow");
abort();
}
congress_object_t congress_object(const congress_t* s){
int v = s->object_ ;
if(v<=0) {return (congress_object_t){.type=CONGRESS_NONE}; }
if(v<=4) {return (congress_object_t){.type=CONGRESS_PERSON, .person=PERSON_TABLE+v-1}; }
if(v<=7) {return (congress_object_t){.type=CONGRESS_LETTERCASE, .lettercase=LETTERCASE_TABLE+v-5}; }
perror("insrcdata variant index overflow");
abort();
}