open-source-search-engine/CountryCode.h

48 lines
1.2 KiB
C
Raw Normal View History

2013-08-03 00:12:24 +04:00
#ifndef _COUNTRYCODE_H
#define _COUNTRYCODE_H
#include "HashTableT.h"
#include "types.h"
// . used by Events.cpp to keep things small
// . get a single byte country id from a 2 character country code
uint8_t getCountryId ( char *cc ) ;
// map a country id to the two letter country abbr
char *getCountryCode ( uint8_t crid );
class CountryCode {
public:
CountryCode();
~CountryCode();
void init(void);
int getNumCodes(void);
const char *getAbbr(int index);
const char *getName(int index);
int getIndexOfAbbr(const char *abbr);
2014-11-11 01:45:11 +03:00
uint16_t getCountryFromDMOZ(int32_t catid);
uint8_t getLanguageFromDMOZ(int32_t catid);
2013-08-03 00:12:24 +04:00
int createHashTable(void);
bool loadHashTable(void);
void reset();
2014-11-11 01:45:11 +03:00
int32_t getNumEntries(void);
2013-08-03 00:12:24 +04:00
void debugDumpNumbers(void);
uint64_t getLanguagesWritten(int index);
private:
int fillRegexTable(void);
void freeRegexTable(void);
int lookupCountryFromDMOZTopic(const char *catname, int len);
bool m_init;
2014-11-11 01:45:11 +03:00
HashTableT<uint16_t, int>m_abbrToIndex;
HashTableT<uint16_t, const char *>m_abbrToName;
2013-08-03 00:12:24 +04:00
};
extern CountryCode g_countryCode;
// We're currently at 24x or so...
#define MAX_COUNTRIES (255)
#endif // _COUNTRYCODE_H