void nmTextSubtitles::strToIntMargin(const ffstring &str,int *i) { if (!str.empty() /*str.size()==4 && str.compare(_L("0000"))!=0*/) { wchar_t *end; int val=strtol(str.c_str(),&end,10); if (*end=='\0' && val>0) { *i=val; } } }
void nmTextSubtitles::strToDouble(const ffstring &str,double *d) { if (!str.empty()) { wchar_t *end; double val=strtod(str.c_str(),&end); if (*end=='\0') { *d=val; } } }
bool TSSAstyle::toCOLORREF(const ffstring& colourStr,COLORREF &colour,int &alpha) { if (colourStr.empty()) { return false; } int radix; ffstring s1,s2; s1=colourStr; s1.ConvertToUpperCase(); if (s1.compare(0,2,L"&H",2)==0) { s1.erase(0,2); radix=16; } else { if (s1.compare(0,1,L"-",1)==0) { colour=0x000000; alpha=256; return true; } radix=10; } s2=s1; if (s1.size()>6) { s1.erase(s1.size()-6,6); s2.erase(0,s2.size()-6); } else { s1.clear(); } int msb=0; if (!s1.empty()) { const wchar_t *alphaS=s1.c_str(); wchar_t *endalpha; long a=strtol(alphaS,&endalpha,radix); if (*endalpha=='\0') { msb=a; } } if (s2.empty()) { return false; } const wchar_t *colorS=s2.c_str(); wchar_t *endcolor; COLORREF c=strtol(colorS,&endcolor,radix); if (*endcolor=='\0') { DWORD result=msb * (radix==16 ? 0x1000000 : 1000000) + c; colour=result & 0xffffff; alpha=256-(result>>24); return true; }
void nmTextSubtitles::strToInt(const ffstring &str,int *i) { if (!str.empty()) { if (str.compare(0,4,L" yes",4)==0) { *i = 1; return; } else if (str.compare(0,3,L" no",3)==0) { *i = 0; return; } wchar_t *end; int val=strtol(str.c_str(),&end,10); if (*end=='\0' && val>=0) { *i=val; } } }