Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.
Become a Premium Member and unlock a new, free course in leading technologies each month.
static struct
{
TCHAR org_openbddb[41];
TCHAR cross_openbddb[41];
} openbddb_matrix[] = {
/* The ISO 639 language codes.
*/
{_T("ec62b87bfd5585ac8be5c7fb0cbba1ce6a29c0bd"), _T("ec62b87bfd5585ac8be5c7fb0cbba1ce6a29c0bd")},
};
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
#include <map>
using namespace std;
static struct
{
TCHAR org_openbddb[41];
TCHAR cross_openbddb[41];
} openbddb_matrix[] = {
/* The ISO 639 language codes.
*/
{_T("ec62b87bfd5585ac8be5c7fb0cbba1ce6a29c0bd"), _T("ec62b87bfd5585ac8be5c7fb0cbba1ce6a29c0bd")},
{NULL, NULL} // I assume this is at the end
};
// ...
typedef std::string<TCHAR> tstring;
map<tstring,tstring> map_lang_code;
// store all in map
int n = 0;
while(openbddb_matrix[n].org_openbddb) {
map_lang.code.insert(map<tstring,tstring>::value_type(openbddb_matrix[i].org_openbddb,openbddb_matrix[i].cross_openbddb));
++n;
}
TCHAR* lookup_org_value(const TCHAR* val) {
// lookup
map<tstring,tstring>::iterator i;
// e.g. like: i = map_lang_code.find(_T("ec62b87bfd5585ac8be5c7fb0cbba1ce6a29c0bd"));
i = map_lang_code.find(val);
if (i != map_lang_code.end()) return i->second; // found it
return NULL; // nothing found
}
TCHAR* lookup_org_value(const TCHAR* val) {
int n = 0;
while(openbddb_matrix[n].org_openbddb) {
if (!_tcscmp(openbddb_matrix[n].org_openbddb,val)) return openbddb_matrix[n].cross_openbddb; // found it
++n;
}
return NULL; // nothing found
}
ec62b87bfd5585ac8be5c7fb0cbba1ce6a29c0bd
the codes seem to be 20 unsigned 8-bit integers (bytes) in hex notation. if so, you could spare more than half the size if you convert them to binary integers. if your TCHAR is a wide character the saving would be more than 3/4 of the size needed for strings.class LangCode
{
unsigned char codes[20];
public:
LangCode() { memset(codes, 0, sizeof(codes)); }
LangCode(TCHAR scod[])
{
assert(_tcslen(scod) == 40);
char szt[3] = { '\0' };
for (int i = 0, j = 0; i < 40; i += 2, j++)
{
szt[0] = (char)scod[i];
szt[1] = (char)scod[i+1];
std::istringstream iss(szt);
iss >> std::hex >> codes[j];
assert(iss);
}
}
bool operator<(const LangCode& lc) const
{ return memcmp(codes, lc.codes, sizeof(codes)) < 0; }
};
TCHAR * psz1 = L"ec62b87bfd5585ac8be5c7fb0cbba1ce6a29c0bd";
TCHAR * psz2 = L"23b87bfd5585ac8fffc7fb0cba1ba1ce6a200000";
std::map<LangCode, LangCode> maplc;
maplc[psz1] = psz2;
...
std::map<LangCode, LangCode>::iterator f;
if ((f = maplc.find(psz1)) != maplc.end())
{
std::cout << "found" << std::endl;
}
else
{
std::cout << "not found" << std::endl;
}
struct LCPair
{
LangCode lc1;
LangCode lc2;
};
LCPair matrix[] =
{
{_T("ec62b87bfd5585ac8be5c7fb0cbba1ce6a29c0bd"),
_T("23b87bfd5585ac8fffc7fb0cba1ba1ce6a200000") },
{_T("ff62b87bfd5325ac8be5c7fb0cbba1ce6a29c0bd"),
_T("11111afd5585ac8fffc7fb0cba1ba1ce6a200000")},
....
};
for (size_t n = 0; n < sizeof(matrix)/sizeof(matrix[0]); ++n)
maplc[matrix[n].lc1] = matrix[n].lc2;
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.