Thursday, August 27, 2009

List - Iterator

for(list::iterator it=m_pptInitialSlideIDListNew.begin(); it!=m_pptInitialSlideIDListNew.end(); it++)
{
int iSlideIDCurrent = *it;
}

Tuesday, August 25, 2009

Reference

http://www.cplusplus.com/reference/stl/list/

Thursday, August 13, 2009

doubleToString

SDBString_ptr SDBUtil::doubleToString(double number) {
char buffer[64];
sprintf(buffer, "%f", number);

//int count, count2;
for(char* p = buffer + strlen(buffer) - 1; p >= buffer; p--) {
if (*p == '0') {
*p = '\0';
} else {
if (*p == '.') {
*p = '\0';
}
break;
}
}

return new SDBString(buffer);
}

stringToDouble

double SDBUtil::stringToDouble(char* data) {
int foundDot = 0;
for(char* p = data; *p; p++) {
if (isdigit(*p)) {
continue;
} else if (*p == '.') {
if (foundDot) {
throw strdup("Input wrong float");
} else {
foundDot = 1;
}
} else {
throw strdup("Input wrong float");
}
}
if (!foundDot) {
throw strdup("Input wrong float");
}
return atof(data);
}

stringToLong

long SDBUtil::stringToLong(char* data) {
for(char* p = data; *p; p++) {
if (!isdigit(*p)) {
throw strdup("Input wrong integer");
}
}
return atol(data);
}