- attempt to switch CRC to use unsigned int everywhere

This commit is contained in:
Mark Vejvoda
2012-07-07 02:46:57 +00:00
parent bf0e76c5e7
commit 4202989014
24 changed files with 327 additions and 225 deletions

View File

@@ -49,6 +49,18 @@ int strToInt(const string &s){
return intValue;
}
uint32 strToUInt(const string &s){
char *endChar;
setlocale(LC_NUMERIC, "C");
uint32 intValue= strtoul(s.c_str(), &endChar, 10);
if(*endChar!='\0'){
throw megaglest_runtime_error("Error converting from string to uint, found: [" + s + "]");
}
return intValue;
}
float strToFloat(const string &s){
char *endChar;
@@ -88,6 +100,18 @@ bool strToInt(const string &s, int *i) {
return true;
}
bool strToUInt(const string &s, uint32 *i) {
char *endChar;
setlocale(LC_NUMERIC, "C");
*i= strtoul(s.c_str(), &endChar, 10);
if(*endChar!='\0'){
return false;
}
return true;
}
bool strToFloat(const string &s, float *f) {
char *endChar;
setlocale(LC_NUMERIC, "C");
@@ -114,6 +138,12 @@ string intToStr(int64 i) {
return (str[0] != '\0' ? str : "");
}
string uIntToStr(uint32 i) {
char str[strSize]="";
snprintf(str, strSize-1, "%u", i);
return (str[0] != '\0' ? str : "");
}
string intToHex(int i){
char str[strSize]="";
snprintf(str, strSize-1, "%x", i);