diff --git a/src/System/Convert/ConvertType.h b/src/System/Convert/ConvertType.h deleted file mode 100644 index 9d7dead..0000000 --- a/src/System/Convert/ConvertType.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#ifndef INCLUDED_CASSERT -#define INCLUSED_CASSERT -#include -#endif - -template -struct ConvertBase { - enum { charCount = sizeof(T) }; - union Values { - unsigned char c[charCount]; - T t; - }; - - Values value; - - int GetSize(void) const { return charCount; } -}; - -template -struct ConvertFrom: private ConvertBase { - explicit ConvertFrom(const T& t) { - this->value.t = t; - } - using ConvertBase::GetSize; - - unsigned char GetByte(int index) const { - assert((index >= 0) && (index < GetSize())); - return this->value.c[index]; - } -}; - -template -struct ConvertTo: private ConvertBase { - using ConvertBase::GetSize; - - void SetByte(int index, unsigned char c) { - assert((index >= 0) && (index < GetSize())); - this->value.c[index] = c; - } - - const T& GetValue(void) const { - return this->value.t; - } -}; - -typedef unsigned short uint16_t; diff --git a/src/System/Convert/str2int.cpp b/src/System/Convert/str2int.cpp deleted file mode 100644 index d512d2b..0000000 --- a/src/System/Convert/str2int.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include -#include "str2int.h" - -char convert_strbuf[16]; - -// I'm presuming 32 bit int.. - -int _last_str2int_errno = 0; - -char* int2str(int value) { - int tmp; - int expv; - int strpos = 0; - - if(value < 0) { - convert_strbuf[0] = '-'; - strpos++; - value = -value; - } - - for(expv = 1000000000; expv > 1; expv /= 10) { - if((value / expv) != 0) break; - } - - for( ; expv > 0; expv /= 10) { - tmp = (value/expv); - value -= tmp * expv; - convert_strbuf[strpos] = (char)('0' + tmp); - strpos++; - } - convert_strbuf[strpos] = '\0'; - return convert_strbuf; -} - -// Does not check for possible overflow.. -int str2int(const char* string) { - int i; - int len = strlen(string); - int value = 0; - int exp = 1; - - if(len > 11) { - _last_str2int_errno = 1; - return 0; - } - - for(i = len - 1; i >= 0; i--) { - if(string[i] >= '0' && string[i] <= '9') { - value+=(string[i] - '0') * exp; - exp *= 10; - } else { - if(i == 0) { - if(string[0] == '-') { - _last_str2int_errno = 0; - return -value; - } - } - _last_str2int_errno = 1; - return 0; - } - } - _last_str2int_errno = 0; - return value; -} - -int str2int_errno(void) { - return _last_str2int_errno; -} - -char* time2str(int secs) { - if(secs < 0) { - return "00:00:00"; - } - int max_secs = 99 + 99*60 + 99*60*60; - if(secs > max_secs) { - secs = max_secs; - } - - // Fill. - int hours = secs / 3600; - int mins = (secs - hours * 3600) / 60; - int sex = (secs - hours * 3600 - mins * 60); - int timeVal[3] = {hours, mins, sex}; - - int tmp; - int strpos = 0; - - for(int i = 0; i < 3; i++) { - int value = timeVal[i]; - if(value > 100) value = 99; - - int expv = 10; - if((value / expv) == 0) { - expv = 1; - // Zero padding. - convert_strbuf[strpos] = '0'; - strpos++; - } - for( ; expv > 0; expv /= 10) { - tmp = (value / expv); - value -= tmp * expv; - convert_strbuf[strpos] = (char)('0' + tmp); - strpos++; - } - if(i < 2) { - convert_strbuf[strpos] = ':'; - strpos++; - } - } - convert_strbuf[strpos] = '\0'; - return convert_strbuf; -} - diff --git a/src/System/Convert/str2int.h b/src/System/Convert/str2int.h deleted file mode 100644 index 1f6cece..0000000 --- a/src/System/Convert/str2int.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -extern char* int2str(int value); -extern int str2int(const char* string); -extern int str2int_errno(void); -extern char* time2str(int secs); // hh:mm::ss. -