Date and Calendar Analytics
country.cpp

This is an example program how to call the country related APIS More details about this example.

Note
The example here references two functions defined in dbm_init.cpp file:
  • dbm_example_init
  • dbm_example_shutdown
#include <windows.h>
#include <iostream>
#include <string>
#include "SFLOG.h"
#include "SFDBM.h"
bool dbm_example_init(void);
void dbm_example_shutdown(void);
int main(){
// initialize the logging, licesne and then the calendar module here ..
if(!dbm_example_init()){
std::wcout << L" ERROR - Failed to initialize the sdk. Exit!" << std::endl;
return -1;
}
// country code is "US" (ISO-2 code)
int nRetCode = SFDB_ISVALIDCNTRYCODE(L"US");
if( nRetCode == NDK_TRUE){
std::wcout << L" SUCCESS - SFDB_ISVALIDCNTRYCODE for US is valid." << std::endl;
}
// country code is "US" (ISO-3 code)
nRetCode = SFDB_ISVALIDCNTRYCODE(L"GBR");
if( nRetCode == NDK_TRUE){
std::wcout << L" SUCCESS - SFDB_ISVALIDCNTRYCODE for GBR is valid." << std::endl;
}
// country code is "UK"
std::wstring szCode(TEXT("GB"));
size_t nLen=28;
std::vector<TCHAR> szBuffer(nLen, 0x00);
nRetCode = SFDB_GETWKNDFROMCNTRY(L"GB", &szBuffer[0],&nLen); // Expected: 0000011
if(nRetCode == NDK_SUCCESS){
std::wstring szWknCode = &szBuffer[0];
std::wcout << L" SUCCESS - SFDB_GETWKNDFROMCNTRY for GB is: " << szWknCode << std::endl;
}
// country code is "UK"
nLen=szBuffer.size();
wmemset(&szBuffer[0], TCHAR(0), nLen);
nRetCode = SFDB_GETCALFROMCNTRY(L"GB", &szBuffer[0],&nLen);
if(nRetCode == NDK_SUCCESS){
std::wstring szCalCode = &szBuffer[0];
std::wcout << L" SUCCESS - SFDB_GETCALFROMCNTRY for GB is: " << szCalCode << std::endl;
}
// shutdown the calendar, license and logging module here.
dbm_example_shutdown();
return 0;
}
int __stdcall SFDB_GETCALFROMCNTRY(LPCTSTR argCode, LPTSTR retVal, size_t *nLen)
Return the calendar code associated with the given country.
Definition country.cpp:210
int __stdcall SFDB_ISVALIDCNTRYCODE(LPCTSTR argCode)
Return TRUE if the country code is a valid ISO country code (2 or 3 characters)
Definition country.cpp:47
int __stdcall SFDB_GETWKNDFROMCNTRY(LPCTSTR argCode, LPTSTR retVal, size_t *nLen)
Return the weekend convention of the government calendar of the given country.
Definition country.cpp:118
#define NDK_TRUE
#define NDK_SUCCESS