/** ******************************************************************************* @file /common/utils.h @brief Spolecne funkce. @author Vajicek @version 0.1 ******************************************************************************/ #ifndef UTILS_H #define UTILS_H #include #include /** uzitecne funkce */ #ifndef MAX #define MAX(a,b) (((a)>(b))?(a):(b)) #endif #ifndef MIN #define MIN(a,b) (((a)>(b))?(b):(a)) #endif #define ABS(a) ((a)>0?(a):(-1)*(a)) #define ODD(a) ((a)%2) #define EVEN(a) (!((a)%2)) int roundReal(double a); int roundReal(float a); int mmin(int count, int x, ...); int mmax(int count, int x, ...); /** konverze mezi utf a widechar */ //@{ /** Prevede retezec kodovany v UTF8 do retezce WideCharu. @param utf8 Zdroj. @param wch Cil. @param bufsize Delka bufferu. @return Buffer wch, nebo NULL pokud nestacil, ale i tak se da nakonec 0. */ extern wchar_t* UTF8toWideChar(const char* utf8, wchar_t* wch, int bufsize); /** Prevede retezec WideCharu do obycejnecho retezece zakodovanem v UTF8. @param wch Zdroj. @param utf8 Cil. @param bufsize Delka bufferu. @return Buffer utf8, nebo NULL pokud nestacil, ale i tak se da nakonec 0. */ extern char* WideChartoUTF8(const wchar_t* wch, char* utf8, int bufsize); /** Spocita kolik znaku bude zabirat retezec wch po konverzi do UTF8, nepocita koncovou nulu. @param wch Retezec. @return Delka retezce v UTF8. */ extern int WideCharlen(const wchar_t* wch); /** Delka retezce v UTF8. Spocita kolik znaku bude zabirat retezec utf8 po konverzi do WideChar, nepocita koncovou nulu @param utf8 Retezec. @return Delka retezce v utf; */ extern int UTF8len(const char* utf8); // nepocita koncovy NULL //@} /** Funkce na zjisteni id hexu na jihozapad od zadaneho hexu @param id index hexu @param sizex sirka mapy */ int SW(int id,int sizex); /** Funkce na zjisteni id hexu na jihovychod od zadaneho hexu @param id index hexu @param sizex sirka mapy */ int SE(int id,int sizex); /** Funkce na zjisteni id hexu na jih od zadaneho hexu @param id index hexu @param sizex sirka mapy */ int S(int id,int sizex); /** Funkce na zjisteni id hexu na severozapad od zadaneho hexu @param id index hexu @param sizex sirka mapy */ int NW(int id,int sizex); /** Funkce na zjisteni id hexu na severovychod od zadaneho hexu @param id index hexu @param sizex sirka mapy */ int NE(int id,int sizex); /** Funkce na zjisteni id hexu na sever od zadaneho hexu @param id index hexu @param sizex sirka mapy */ int N(int id,int sizex); #endif /*****************************************************************************/