1
0
forked from 0ad/0ad

removed obsoleted _int etc. typedefs

This was SVN commit r332.
This commit is contained in:
janwas 2004-06-01 16:51:37 +00:00
parent e555221221
commit bf846be6f5
13 changed files with 205 additions and 228 deletions

View File

@ -17,7 +17,7 @@ DEFINE_ERROR(ERRONEOUS_BOUND_ERROR, "Lower Bound is >= Upper Bound");
// PURPOSE: Returns true if two floating point numbers are within
// FL_FP_TOLERANCE of each other.
//
_bool MathUtil::CompareFloat(const _double &num1, const _double &num2)
bool MathUtil::CompareFloat(const double &num1, const double &num2)
{
if( Abs(num1 - num2) < FL_FP_TOLERANCE )
return true;
@ -30,7 +30,7 @@ _bool MathUtil::CompareFloat(const _double &num1, const _double &num2)
// NAME: RadiansToDegrees
// PURPOSE: Converts from Radians to Degrees
//
inline _double MathUtil::RadiansToDegrees(const _double &num)
inline double MathUtil::RadiansToDegrees(const double &num)
{
return num*(PI/180);
}
@ -40,7 +40,7 @@ inline _double MathUtil::RadiansToDegrees(const _double &num)
// NAME: RadiansToDegrees
// PURPOSE: Converts from Degrees to Radians
//
inline _double MathUtil::DegreesToRadians(const _double &num)
inline double MathUtil::DegreesToRadians(const double &num)
{
return (num*180)/PI;
}
@ -52,7 +52,7 @@ inline _double MathUtil::DegreesToRadians(const _double &num)
// and upperBound
// NOTES: returns -1 if lowerBound >= upperBound
//
_float MathUtil::Random(const _float &lowerBound, const _float &upperBound)
float MathUtil::Random(const float &lowerBound, const float &upperBound)
{
if( lowerBound >= upperBound)
@ -63,7 +63,7 @@ _float MathUtil::Random(const _float &lowerBound, const _float &upperBound)
srand( static_cast<unsigned>( time(NULL) ) );
// finds a floating point number between 0 and 1.0
_float randVar = ( static_cast<_float>( rand() )/RAND_MAX );
float randVar = ( static_cast<float>( rand() )/RAND_MAX );
// maps the number onto the set from 0 to upperBound
randVar *= Abs(lowerBound - upperBound ) + 1;
@ -81,7 +81,7 @@ _float MathUtil::Random(const _float &lowerBound, const _float &upperBound)
// PURPOSE: returns a random number between lowerBound and upperBound
// NOTES: returns -1 if lowerBound >= upperBound
//
_int MathUtil::Random(const _int &lowerBound,const _int &upperBound)
int MathUtil::Random(const int &lowerBound,const int &upperBound)
{
if( lowerBound >= upperBound)
return -1;
@ -91,7 +91,7 @@ _int MathUtil::Random(const _int &lowerBound,const _int &upperBound)
srand( static_cast<unsigned>( time(NULL) ) );
// find a random variable between 0 and range size
_int randVar = rand()%( Abs(upperBound - lowerBound) + 1);
int randVar = rand()%( Abs(upperBound - lowerBound) + 1);
// translate to proper range
randVar += lowerBound;
@ -107,12 +107,12 @@ _int MathUtil::Random(const _int &lowerBound,const _int &upperBound)
// NOTES: Round rounds to the nearest representable number
// float version.
//
_int MathUtil::Round(const float &num)
int MathUtil::Round(const float &num)
{
if( num > 0 )
return static_cast<_int>(num + .5);
return static_cast<int>(num + .5);
else if (num < 0 )
return static_cast<_int>(num - .5);
return static_cast<int>(num - .5);
else
return 0;
}
@ -124,12 +124,12 @@ _int MathUtil::Round(const float &num)
// NOTES: Round rounds to the nearest representable number
// double version.
//
_int MathUtil::Round(const double &num)
int MathUtil::Round(const double &num)
{
if( num > 0 )
return static_cast<_int>(num + .5);
return static_cast<int>(num + .5);
else if (num < 0 )
return static_cast<_int>(num - .5);
return static_cast<int>(num - .5);
else
return 0;
}
@ -139,7 +139,7 @@ _int MathUtil::Round(const double &num)
// NAME: SignedModulus
// PURPOSE: returns a mathematically correct modulus for int
//
_int MathUtil::SignedModulus(const _int &num, const _int &n)
int MathUtil::SignedModulus(const int &num, const int &n)
{
if( num >= 0 )
return num%n;
@ -148,7 +148,7 @@ _int MathUtil::SignedModulus(const _int &num, const _int &n)
// the % operator reflects the range if num < 0, so
// we have to multiply by -1 to reflect it back. This method
// is faster than calling Abs() and then doing the modulus.
_int Tnum = -1*(num%n);
int Tnum = -1*(num%n);
// if num%n equals 0, then n - Tnum will be n, which, logically
// speaking, is 0 in a different form, but we have to make sure it's
@ -166,7 +166,7 @@ _int MathUtil::SignedModulus(const _int &num, const _int &n)
// NAME: SignedModulus
// PURPOSE: returns a mathematically correct modulus for long
//
_long MathUtil::SignedModulus(const _long &num, const _long &n)
long MathUtil::SignedModulus(const long &num, const long &n)
{
if( num >= 0 )
return num%n;
@ -175,7 +175,7 @@ _long MathUtil::SignedModulus(const _long &num, const _long &n)
// the % operator reflects the range if num < 0, so
// we have to multiply by -1 to reflect it back. This method
// is faster than calling Abs() and then doing the modulus.
_long Tnum = -1*(num%n);
long Tnum = -1*(num%n);
// if num%n equals 0, then n - Tnum will be n, which, logically
// speaking, is 0 in a different form, but we have to make sure it's
@ -194,16 +194,16 @@ _long MathUtil::SignedModulus(const _long &num, const _long &n)
// PURPOSE: returns a mathematically correct modulus for float
// NOTES: uses fmod() in math.h, which returns the modulus of floats
//
_float MathUtil::SignedModulus(const _float &num, const _float &n)
float MathUtil::SignedModulus(const float &num, const float &n)
{
if( num >=0 )
return static_cast<_float>( fmod(num,n) );
return static_cast<float>( fmod(num,n) );
else
{
// the % operator reflects the range if num < 0, so
// we have to multiply by -1 to reflect it back. This method
// is faster than calling Abs() and then doing the modulus.
_float Tnum = -1*( static_cast<_float>( fmod(num,n) ) );
float Tnum = -1*( static_cast<float>( fmod(num,n) ) );
// if num%n equals 0, then n - Tnum will be n, which, logically
// speaking, is 0 in a different form, but we have to make sure it's
@ -223,7 +223,7 @@ _float MathUtil::SignedModulus(const _float &num, const _float &n)
// PURPOSE: returns a mathematically correct modulus for double
// NOTES: uses fmod() in math.h, which returns the modulus of floats
//
_double MathUtil::SignedModulus(const _double &num, const _double &n)
double MathUtil::SignedModulus(const double &num, const double &n)
{
if( num >=0 )
return fmod(num,n);
@ -232,7 +232,7 @@ _double MathUtil::SignedModulus(const _double &num, const _double &n)
// the % operator reflects the range if num < 0, so
// we have to multiply by -1 to reflect it back. This method
// is faster than calling Abs() and then doing the modulus.
_double Tnum = -1*( fmod(num,n) );
double Tnum = -1*( fmod(num,n) );
// if num%n equals 0, then n - Tnum will be n, which, logically
// speaking, is 0 in a different form, but we have to make sure it's

View File

@ -54,8 +54,8 @@ DECLARE_ERROR(ERRONEOUS_BOUND_ERROR);
namespace MathUtil
{
const _double PI = 3.14159265358932384;
const _double FL_FP_TOLERANCE = .000000001;
const double PI = 3.14159265358932384;
const double FL_FP_TOLERANCE = .000000001;
//--------------------------------------------------------
@ -85,7 +85,7 @@ namespace MathUtil
// PURPOSE: Forces num to be between lowerBound and upperBound
//
template <typename T>
T Clamp(T &num, const _int &lowerBound,const _int &upperBound)
T Clamp(T &num, const int &lowerBound,const int &upperBound)
{
if(num <= lowerBound)
num = static_cast<T>(lowerBound);
@ -128,7 +128,7 @@ namespace MathUtil
// otherwise returns 0.
//
template <typename T>
_int Sign(const T &num)
int Sign(const T &num)
{
if( num > 0 )
return 1;
@ -146,7 +146,7 @@ namespace MathUtil
// maximum representable number for the data type.
//
template <typename T>
inline _double Square(const T &num)
inline double Square(const T &num)
{
return num*num;
}
@ -191,27 +191,27 @@ namespace MathUtil
// Non-template functions
//--------------------------------------------------------
_int Ceiling(const float &num);
_int Ceiling(const double &num);
int Ceiling(const float &num);
int Ceiling(const double &num);
_bool CompareFloat(const _double &, const _double &);
bool CompareFloat(const double &, const double &);
_int Floor(const float &num);
_int Floor(const double &num);
int Floor(const float &num);
int Floor(const double &num);
inline _double RadiansToDegrees(const _double &num);
inline _double DegreesToRadians(const _double &num);
inline double RadiansToDegrees(const double &num);
inline double DegreesToRadians(const double &num);
_float Random(const _float &, const _float &);
_int Random(const _int &,const _int &);
float Random(const float &, const float &);
int Random(const int &,const int &);
_int Round(const float &num);
_int Round(const double &num);
int Round(const float &num);
int Round(const double &num);
_int SignedModulus(const _int &num, const _int &n);
_long SignedModulus(const _long &num, const _long &n);
_float SignedModulus(const _float &num, const _float &n);
_double SignedModulus(const _double &num, const _double &n);
int SignedModulus(const int &num, const int &n);
long SignedModulus(const long &num, const long &n);
float SignedModulus(const float &num, const float &n);
double SignedModulus(const double &num, const double &n);
}
#endif

View File

@ -29,41 +29,41 @@ CStr::CStr(TCHAR Char)
m_String = Char;
}
CStr::CStr(_int Number)
CStr::CStr(int Number)
{
// Creates CStr from a int
m_String = _itot(Number, m_ConversionBuffer, 10);
}
CStr::CStr(_uint Number)
CStr::CStr(unsigned int Number)
{
// Creates CStr from a uint
m_String = _ultot(Number, m_ConversionBuffer, 10);
}
CStr::CStr(_long Number)
CStr::CStr(long Number)
{
// Creates CStr from a long
m_String = _ltot(Number, m_ConversionBuffer, 10);
}
CStr::CStr(_ulong Number)
CStr::CStr(unsigned long Number)
{
// Creates CStr from a ulong
m_String = _ultot(Number, m_ConversionBuffer, 10);
}
CStr::CStr(_float Number)
CStr::CStr(float Number)
{
// Creates CStr from a float
_tsprintf(m_ConversionBuffer, FLOAT_CONVERSION, Number);
m_String = m_ConversionBuffer;
}
CStr::CStr(_double Number)
CStr::CStr(double Number)
{
// Creates CStr from a double
_tsprintf(m_ConversionBuffer, FLOAT_CONVERSION, Number);
@ -76,33 +76,33 @@ CStr::~CStr()
}
_int CStr::ToInt() const
int CStr::ToInt() const
{
return _ttoi(m_String.c_str());
}
_uint CStr::ToUInt() const
unsigned int CStr::ToUInt() const
{
return _uint(_ttoi(m_String.c_str()));
return unsigned int(_ttoi(m_String.c_str()));
}
_long CStr::ToLong() const
long CStr::ToLong() const
{
return _ttol(m_String.c_str());
}
_ulong CStr::ToULong() const
unsigned long CStr::ToULong() const
{
return _ulong(_ttol(m_String.c_str()));
return unsigned long(_ttol(m_String.c_str()));
}
_float CStr::ToFloat() const
float CStr::ToFloat() const
{
return (_float)_tstod(m_String.c_str(), NULL);
return (float)_tstod(m_String.c_str(), NULL);
}
_double CStr::ToDouble() const
double CStr::ToDouble() const
{
return _tstod(m_String.c_str(), NULL);
}
@ -115,9 +115,9 @@ CStr CStr::GetSubstring(size_t start, size_t len) const
//Search the string for another string
_long CStr::Find(const CStr &Str) const
long CStr::Find(const CStr &Str) const
{
_long Pos = (_long)m_String.find(Str.m_String, 0);
long Pos = (long)m_String.find(Str.m_String, 0);
if (Pos != tstring::npos)
return Pos;
@ -126,9 +126,9 @@ _long CStr::Find(const CStr &Str) const
}
//Search the string for another string
_long CStr::Find(const TCHAR &tchar) const
long CStr::Find(const TCHAR &tchar) const
{
_long Pos = (_long)m_String.find(tchar, 0);
long Pos = (long)m_String.find(tchar, 0);
if (Pos != tstring::npos)
return Pos;
@ -137,9 +137,9 @@ _long CStr::Find(const TCHAR &tchar) const
}
//Search the string for another string
_long CStr::Find(const int &start, const TCHAR &tchar) const
long CStr::Find(const int &start, const TCHAR &tchar) const
{
_long Pos = (_long)m_String.find(tchar, start);
long Pos = (long)m_String.find(tchar, start);
if (Pos != tstring::npos)
return Pos;
@ -147,9 +147,9 @@ _long CStr::Find(const int &start, const TCHAR &tchar) const
return -1;
}
_long CStr::ReverseFind(const CStr &Str) const
long CStr::ReverseFind(const CStr &Str) const
{
_long Pos = (_long)m_String.rfind(Str.m_String, m_String.length() );
long Pos = (long)m_String.rfind(Str.m_String, m_String.length() );
if (Pos != tstring::npos)
return Pos;
@ -198,13 +198,13 @@ CStr CStr::UCase() const
}
//Retreive the substring of the first n characters
CStr CStr::Left(_long len) const
CStr CStr::Left(long len) const
{
return CStr( m_String.substr(0, len) );
}
//Retreive the substring of the last n characters
CStr CStr::Right(_long len) const
CStr CStr::Right(long len) const
{
return CStr( m_String.substr(m_String.length()-len, len) );
}
@ -298,71 +298,71 @@ CStr &CStr::operator=(TCHAR Char)
return *this;
}
CStr &CStr::operator=(_int Number)
CStr &CStr::operator=(int Number)
{
m_String = _itot(Number, m_ConversionBuffer, 10);
return *this;
}
CStr &CStr::operator=(_long Number)
CStr &CStr::operator=(long Number)
{
m_String = _ltot(Number, m_ConversionBuffer, 10);
return *this;
}
CStr &CStr::operator=(_uint Number)
CStr &CStr::operator=(unsigned int Number)
{
m_String = _ultot(Number, m_ConversionBuffer, 10);
return *this;
}
CStr &CStr::operator=(_ulong Number)
CStr &CStr::operator=(unsigned long Number)
{
m_String = _ultot(Number, m_ConversionBuffer, 10);
return *this;
}
CStr &CStr::operator=(_float Number)
CStr &CStr::operator=(float Number)
{
_tsprintf(m_ConversionBuffer, FLOAT_CONVERSION, Number);
m_String = m_ConversionBuffer;
return *this;
}
CStr &CStr::operator=(_double Number)
CStr &CStr::operator=(double Number)
{
_tsprintf(m_ConversionBuffer, FLOAT_CONVERSION, Number);
m_String = m_ConversionBuffer;
return *this;
}
_bool CStr::operator==(const CStr &Str) const
bool CStr::operator==(const CStr &Str) const
{
return (m_String == Str.m_String);
}
_bool CStr::operator!=(const CStr &Str) const
bool CStr::operator!=(const CStr &Str) const
{
return (m_String != Str.m_String);
}
_bool CStr::operator<(const CStr &Str) const
bool CStr::operator<(const CStr &Str) const
{
return (m_String < Str.m_String);
}
_bool CStr::operator<=(const CStr &Str) const
bool CStr::operator<=(const CStr &Str) const
{
return (m_String <= Str.m_String);
}
_bool CStr::operator>(const CStr &Str) const
bool CStr::operator>(const CStr &Str) const
{
return (m_String > Str.m_String);
}
_bool CStr::operator>=(const CStr &Str) const
bool CStr::operator>=(const CStr &Str) const
{
return (m_String >= Str.m_String);
}
@ -391,24 +391,24 @@ CStr::operator const TCHAR*() const
}
TCHAR &CStr::operator[](_int n)
TCHAR &CStr::operator[](int n)
{
assert((size_t)n < m_String.length());
return m_String[n];
}
TCHAR &CStr::operator[](_uint n)
TCHAR &CStr::operator[](unsigned int n)
{
assert(n < m_String.length());
return m_String[n];
}
TCHAR &CStr::operator[](_long n)
TCHAR &CStr::operator[](long n)
{
assert((size_t)n < m_String.length());
return m_String[n];
}
TCHAR &CStr::operator[](_ulong n)
TCHAR &CStr::operator[](unsigned long n)
{
assert(n < m_String.length());
return m_String[n];

View File

@ -12,7 +12,7 @@ Overview:
Example:
CStr MyString = _T("Hello, World.");
_int MyNum = 126;
int MyNum = 126;
MyString += _T(" I'm the number ") += CStr(MyNumber);
// Prints "Hello, World. I'm the number 126"
@ -102,37 +102,37 @@ public:
CStr(tstring String); // Creates CStr from C++ string
CStr(const TCHAR* String); // Creates CStr from C-Style TCHAR string
CStr(TCHAR Char); // Creates CStr from a TCHAR
CStr(_int Number); // Creates CStr from a int
CStr(_uint Number); // Creates CStr from a uint
CStr(_long Number); // Creates CStr from a long
CStr(_ulong Number); // Creates CStr from a ulong
CStr(_float Number); // Creates CStr from a float
CStr(_double Number); // Creates CStr from a double
CStr(int Number); // Creates CStr from a int
CStr(unsigned int Number); // Creates CStr from a uint
CStr(long Number); // Creates CStr from a long
CStr(unsigned long Number); // Creates CStr from a ulong
CStr(float Number); // Creates CStr from a float
CStr(double Number); // Creates CStr from a double
~CStr(); // Destructor
// Conversions
_int ToInt() const;
_uint ToUInt() const;
_long ToLong() const;
_ulong ToULong() const;
_float ToFloat() const;
_double ToDouble() const;
int ToInt() const;
unsigned int ToUInt() const;
long ToLong() const;
unsigned long ToULong() const;
float ToFloat() const;
double ToDouble() const;
size_t Length() const {return m_String.length();}
// Retrieves the substring within the string
CStr GetSubstring(size_t start, size_t len) const;
//Search the string for another string
_long Find(const CStr &Str) const;
long Find(const CStr &Str) const;
//Search the string for another string
_long Find(const TCHAR &tchar) const;
long Find(const TCHAR &tchar) const;
//Search the string for another string
_long Find(const int &start, const TCHAR &tchar) const;
long Find(const int &start, const TCHAR &tchar) const;
//You can also do a "ReverseFind"- i.e. search starting from the end
_long ReverseFind(const CStr &Str) const;
long ReverseFind(const CStr &Str) const;
// Lowercase and uppercase
CStr LowerCase() const;
@ -143,10 +143,10 @@ public:
CStr UCase() const;
// Retreive the substring of the first n characters
CStr Left(_long len) const;
CStr Left(long len) const;
// Retreive the substring of the last n characters
CStr Right(_long len) const;
CStr Right(long len) const;
//Remove all occurences of some character or substring
void Remove(const CStr &Str);
@ -161,27 +161,27 @@ public:
CStr &operator=(const CStr &Str);
CStr &operator=(const TCHAR* String);
CStr &operator=(TCHAR Char);
CStr &operator=(_int Number);
CStr &operator=(_long Number);
CStr &operator=(_uint Number);
CStr &operator=(_ulong Number);
CStr &operator=(_float Number);
CStr &operator=(_double Number);
CStr &operator=(int Number);
CStr &operator=(long Number);
CStr &operator=(unsigned int Number);
CStr &operator=(unsigned long Number);
CStr &operator=(float Number);
CStr &operator=(double Number);
_bool operator==(const CStr &Str) const;
_bool operator!=(const CStr &Str) const;
_bool operator<(const CStr &Str) const;
_bool operator<=(const CStr &Str) const;
_bool operator>(const CStr &Str) const;
_bool operator>=(const CStr &Str) const;
bool operator==(const CStr &Str) const;
bool operator!=(const CStr &Str) const;
bool operator<(const CStr &Str) const;
bool operator<=(const CStr &Str) const;
bool operator>(const CStr &Str) const;
bool operator>=(const CStr &Str) const;
CStr &operator+=(const CStr &Str);
CStr operator+(const CStr &Str);
operator const TCHAR*();
operator const TCHAR*() const; // Gee, I've added this, Maybe the one above should be removed?
TCHAR &operator[](_int n);
TCHAR &operator[](_uint n);
TCHAR &operator[](_long n);
TCHAR &operator[](_ulong n);
TCHAR &operator[](int n);
TCHAR &operator[](unsigned int n);
TCHAR &operator[](long n);
TCHAR &operator[](unsigned long n);
inline const char *c_str()
{ return m_String.c_str(); }

View File

@ -110,8 +110,8 @@ PS_RESULT CConfig::Register( CStr Filename, void* Data, LoaderFunction DynamicLo
PS_RESULT CConfig::Update()
{
_int slice = 0;
_int failed = 0;
int slice = 0;
int failed = 0;
struct stat FileInfo;
for( slice = 0; ( i != m_FileList.end() ) && ( slice < CONFIG_SLICE ); i++ )
@ -211,8 +211,8 @@ PS_RESULT CConfig::Update()
PS_RESULT CConfig::ReloadAll()
{
// Mostly identical to Update(), above.
_int failed = 0;
_int notfound = 0;
int failed = 0;
int notfound = 0;
struct stat FileInfo;
for( i = m_FileList.begin(); i != m_FileList.end(); i++ )

View File

@ -8,19 +8,19 @@
// for the encrypted copy of the data via new[], It is the responsiblity of the user
// to call delete[].
//--------------------------------------------------------------------
_byte *EncryptData(_byte *Data, _long DataLength, _byte *Key, _long KeyLength)
char *EncryptData(char *Data, long DataLength, char *Key, long KeyLength)
{
// Allocate space for new Encrypted data
_byte *NewData = new _byte[DataLength];
char *NewData = new char[DataLength];
// A counter to hold our absolute position in data
_long DataOffset = 0;
long DataOffset = 0;
// Loop through Data until end is reached
while (DataOffset < DataLength)
{
// Loop through the key
for (_long KeyOffset = 0; KeyOffset < KeyLength; KeyOffset++)
for (long KeyOffset = 0; KeyOffset < KeyLength; KeyOffset++)
{
// If were at end of data break and the the while loop should end as well.
if (DataOffset >= DataLength)
@ -50,19 +50,19 @@ _byte *EncryptData(_byte *Data, _long DataLength, _byte *Key, _long KeyLength)
// for the decrypted copy of the data via new[], It is the responsiblity of the user
// to call delete[].
//--------------------------------------------------------------------
_byte *DecryptData(_byte *Data, _long DataLength, _byte *Key, _long KeyLength)
char *DecryptData(char *Data, long DataLength, char *Key, long KeyLength)
{
// Allocate space for new Decrypted data
_byte *NewData = new _byte[DataLength];
char *NewData = new char[DataLength];
// A counter to hold our absolute position in data
_long DataOffset = 0;
long DataOffset = 0;
// Loop through Data until end is reached
while (DataOffset < DataLength)
{
// Loop through the key
for (_long KeyOffset = 0; KeyOffset < KeyLength; KeyOffset++)
for (long KeyOffset = 0; KeyOffset < KeyLength; KeyOffset++)
{
// If were at end of data break and the the while loop should end as well.
if (DataOffset >= DataLength)

View File

@ -7,10 +7,10 @@ Two simple functions for encrypting and decrypting data. The KeyLength is
specified in bytes, therefore Keys must be in multiples of 8 bits. I'd
advice using 128bit keys which you can define as such.
_byte MyKey[16] = { _byte(0xAF), _byte(0x2B), _byte(0x80), _byte(0x7E),
_byte(0x09), _byte(0x23), _byte(0xCC), _byte(0x95),
_byte(0xB4), _byte(0x2D), _byte(0xF4), _byte(0x90),
_byte(0xB3), _byte(0xC4), _byte(0x2A), _byte(0x3B) };
char MyKey[16] = { char(0xAF), char(0x2B), char(0x80), char(0x7E),
char(0x09), char(0x23), char(0xCC), char(0x95),
char(0xB4), char(0x2D), char(0xF4), char(0x90),
char(0xB3), char(0xC4), char(0x2A), char(0x3B) };
There may be a better way to do this but this looks alright to me.
*/
@ -22,9 +22,9 @@ There may be a better way to do this but this looks alright to me.
#define ENCRYPTION_H
// Simple Encryption function
_byte *EncryptData(_byte *Data, _long DataLength, _byte *Key, _long KeyLength);
char *EncryptData(char *Data, long DataLength, char *Key, long KeyLength);
// Simple Decryption function
_byte *DecryptData(_byte *Data, _long DataLength, _byte *Key, _long KeyLength);
char *DecryptData(char *Data, long DataLength, char *Key, long KeyLength);
#endif

View File

@ -52,7 +52,7 @@ CLogFile::CLogFile()
// Constructor that opens a file.
// 3rd parameter determines whether the error frame is shown.
//-------------------------------------------------
CLogFile::CLogFile(string FileName, string PageTitle, _bool WithFrame)
CLogFile::CLogFile(string FileName, string PageTitle, bool WithFrame)
{
Open(FileName,PageTitle,WithFrame);
@ -104,7 +104,7 @@ PS_RESULT CLogFile::InsertDivide()
//-------------------------------------------------
//Opens an error file. If WithFrame is true then it constructs a framed page.
//-------------------------------------------------
PS_RESULT CLogFile::Open(string FileName, string PageTitle, _bool WithFrame)
PS_RESULT CLogFile::Open(string FileName, string PageTitle, bool WithFrame)
{
if(m_IsFileOpen)
return PS_FAIL;

View File

@ -69,7 +69,7 @@ class PS_DISPLAY_SETTINGS
{
public:
PS_DISPLAY_SETTINGS(_int Line, _char *File, _char *Date, PS_DISPLAY_MODE DisplayMode)
PS_DISPLAY_SETTINGS(int Line, char *File, char *Date, PS_DISPLAY_MODE DisplayMode)
{
line=Line;
file=File;
@ -77,9 +77,9 @@ public:
displayMode=DisplayMode;
}
_int line;
_char *file;
_char *date;
int line;
char *file;
char *date;
PS_DISPLAY_MODE displayMode;
};
@ -94,10 +94,10 @@ public:
//Standard Constructor and destructor.
CLogFile();
~CLogFile();
CLogFile(string FileName, string PageTitle, _bool WithFrame=false);
CLogFile(string FileName, string PageTitle, bool WithFrame=false);
//Opens a file for output the 3rd parameter can be set to true to enable the error frame.
PS_RESULT Open(string FileName, string PageTitle, _bool WithFrame=false);
PS_RESULT Open(string FileName, string PageTitle, bool WithFrame=false);
//Closes the file.
PS_RESULT Close();
@ -133,13 +133,13 @@ public:
PS_RESULT AddLink(string LinkText, string Link, string Colour);
private:
_bool m_IsFileOpen; //Is the file open.
_bool m_HasFrame; //Have frames been enabled.
bool m_IsFileOpen; //Is the file open.
bool m_HasFrame; //Have frames been enabled.
ofstream m_TheFile; //The main file.
ofstream m_ErrorFile; //The error link file, used only for frames.
string m_CurrentColour; //The current colour.
string m_FileName; //The name of the main file.
_int m_ErrNo; //The error number.
int m_ErrNo; //The error number.
//Sets the current alignment of the text.
PS_RESULT SetAlignment(PS_TEXT_ALIGN Align);

View File

@ -20,7 +20,7 @@ using namespace std;
#define FUNC_IMPL_CAST_GETDOUBLE(func_name,type) \
bool CParserValue::func_name(type &ret) \
{ \
_double d; \
double d; \
if (GetDouble(d)) \
return ret = (type)d, true; \
else \
@ -42,15 +42,15 @@ bool CParserLine::func_name(const int & arg, type &ret) \
// Function definitions
//-------------------------------------------------
static bool _IsStrictNameChar(const _char& c);
static bool _IsValueChar(const _char& c);
static bool _IsStrictNameChar(const char& c);
static bool _IsValueChar(const char& c);
// Functions used for checking a character if it belongs to a value
// or not
// Checks ident
static bool _IsStrictNameChar(const _char& c)
static bool _IsStrictNameChar(const char& c)
{
return ((c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
@ -58,7 +58,7 @@ static bool _IsStrictNameChar(const _char& c)
}
// Checks value
static bool _IsValueChar(const _char& c)
static bool _IsValueChar(const char& c)
{
return ((c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
@ -111,10 +111,10 @@ bool CParserValue::GetBool(bool &ret)
}
// double
bool CParserValue::GetDouble(_double &ret)
bool CParserValue::GetDouble(double &ret)
{
// locals
_double TempRet = 0.0;
double TempRet = 0.0;
int Size = (int)m_String.size();
int i;
bool AtLeastOne = false; // Checked if at least one of the loops
@ -189,14 +189,14 @@ bool CParserValue::GetString(std::string &ret)
// These macros include the IMPLEMENTATION of the
// the function in the macro argument for CParserValue
// They use GetDouble, and then type-cast it
FUNC_IMPL_CAST_GETDOUBLE(GetFloat, _float)
FUNC_IMPL_CAST_GETDOUBLE(GetChar, _char)
FUNC_IMPL_CAST_GETDOUBLE(GetShort, _short)
FUNC_IMPL_CAST_GETDOUBLE(GetFloat, float)
FUNC_IMPL_CAST_GETDOUBLE(GetChar, char)
FUNC_IMPL_CAST_GETDOUBLE(GetShort, short)
FUNC_IMPL_CAST_GETDOUBLE(GetInt, int)
FUNC_IMPL_CAST_GETDOUBLE(GetLong, _long)
FUNC_IMPL_CAST_GETDOUBLE(GetUnsignedShort, _ushort)
FUNC_IMPL_CAST_GETDOUBLE(GetUnsignedInt, _uint)
FUNC_IMPL_CAST_GETDOUBLE(GetUnsignedLong, _ulong)
FUNC_IMPL_CAST_GETDOUBLE(GetLong, long)
FUNC_IMPL_CAST_GETDOUBLE(GetUnsignedShort, unsigned short)
FUNC_IMPL_CAST_GETDOUBLE(GetUnsignedInt, unsigned int)
FUNC_IMPL_CAST_GETDOUBLE(GetUnsignedLong, unsigned long)
// CParserTaskTypeNode
// ---------------------------------------------------------------------| Class
@ -276,15 +276,15 @@ bool CParserLine::ClearArguments()
// then it uses the the respective function in CParserValue
FUNC_IMPL_GETARG(GetArgString, GetString, string)
FUNC_IMPL_GETARG(GetArgBool, GetBool, bool)
FUNC_IMPL_GETARG(GetArgChar, GetChar, _char)
FUNC_IMPL_GETARG(GetArgShort, GetShort, _short)
FUNC_IMPL_GETARG(GetArgChar, GetChar, char)
FUNC_IMPL_GETARG(GetArgShort, GetShort, short)
FUNC_IMPL_GETARG(GetArgInt, GetInt, int)
FUNC_IMPL_GETARG(GetArgLong, GetLong, _long)
FUNC_IMPL_GETARG(GetArgUnsignedShort, GetUnsignedShort, _ushort)
FUNC_IMPL_GETARG(GetArgUnsignedInt, GetUnsignedInt, _uint)
FUNC_IMPL_GETARG(GetArgUnsignedLong, GetUnsignedLong, _ulong)
FUNC_IMPL_GETARG(GetArgFloat, GetFloat, _float)
FUNC_IMPL_GETARG(GetArgDouble, GetDouble, _double)
FUNC_IMPL_GETARG(GetArgLong, GetLong, long)
FUNC_IMPL_GETARG(GetArgUnsignedShort, GetUnsignedShort, unsigned short)
FUNC_IMPL_GETARG(GetArgUnsignedInt, GetUnsignedInt, unsigned int)
FUNC_IMPL_GETARG(GetArgUnsignedLong, GetUnsignedLong, unsigned long)
FUNC_IMPL_GETARG(GetArgFloat, GetFloat, float)
FUNC_IMPL_GETARG(GetArgDouble, GetDouble, double)
// ParseString
// ------------------------------------------------------------------| Function
@ -307,8 +307,8 @@ bool CParserLine::ParseString(const CParser& Parser, string strLine)
// Locals
bool Extract=false;
int ExtractPos=0;
_char Buffer[256];
_char Letter[] = {'\0','\0'}; // Letter as string
char Buffer[256];
char Letter[] = {'\0','\0'}; // Letter as string
vector<string> Segments;
string strSub;
int i;
@ -338,7 +338,7 @@ bool CParserLine::ParseString(const CParser& Parser, string strLine)
{
Extract = true;
ExtractPos = i;
memset((void*)Buffer, '\0', sizeof(_char)*256);
memset((void*)Buffer, '\0', sizeof(char)*256);
}
else
// GET STRING BETWEEN QUOTES
@ -826,7 +826,7 @@ bool CParser::InputTaskType(const string& strName, const string& strSyntax)
{
Extract = true;
ExtractPos = i+1; // Skip $
memset((void*)Buffer, '\0', sizeof(_char)*REGULAR_MAX_LENGTH);
memset((void*)Buffer, '\0', sizeof(char)*REGULAR_MAX_LENGTH);
// We don't want to extract '$' so we'll just continue to next loop run
continue;

View File

@ -75,17 +75,17 @@ public:
~CParserValue();
// return is error status
_bool GetString(std::string &ret);
_bool GetBool(_bool &ret);
_bool GetChar(_char &ret); // As number! otherwise use GetString make sure size=1
_bool GetShort(_short &ret);
_bool GetInt(_int &ret);
_bool GetLong(_long &ret);
_bool GetUnsignedShort(_ushort &ret);
_bool GetUnsignedInt(_uint &ret);
_bool GetUnsignedLong(_ulong &ret);
_bool GetFloat(float &ret);
_bool GetDouble(double &ret);
bool GetString(std::string &ret);
bool GetBool(bool &ret);
bool GetChar(char &ret); // As number! otherwise use GetString make sure size=1
bool GetShort(short &ret);
bool GetInt(int &ret);
bool GetLong(long &ret);
bool GetUnsignedShort(unsigned short &ret);
bool GetUnsignedInt(unsigned int &ret);
bool GetUnsignedLong(unsigned long &ret);
bool GetFloat(float &ret);
bool GetDouble(double &ret);
// Memory regardless if it's an int, real, string or whatever
std::string m_String;
@ -116,7 +116,7 @@ public:
// Either the node is a letter or a type, if m_Leter is '\0'
// then check m_Type what it is
_char m_Letter;
char m_Letter;
_ParserValueType m_Type;
std::string m_String; // Used for diverse storage
// mainly for the typeAddArg
@ -129,7 +129,7 @@ public:
// true means AltNode can be looped <...>
// false means AltNode is just an optional part [...]
_bool m_AltNodeRepeatable;
bool m_AltNodeRepeatable;
// Whenever a dynamic argument is used, it's first node is stored in this
// as an alternative node. The parser first checks if there is an
@ -170,29 +170,29 @@ public:
~CParserLine();
std::deque<CParserValue> m_Arguments;
_bool m_ParseOK; // same as ParseString will return
bool m_ParseOK; // same as ParseString will return
std::string m_TaskTypeName; // Name of the task type found
protected:
_bool ClearArguments();
bool ClearArguments();
public:
// Interface
_bool ParseString(const CParser& parser, std::string line);
bool ParseString(const CParser& parser, std::string line);
// Methods for getting arguments
// it returns success
_bool GetArgString (const _int& arg, std::string &ret);
_bool GetArgBool (const _int& arg, _bool &ret);
_bool GetArgChar (const _int& arg, _char &ret);
_bool GetArgShort (const _int& arg, _short &ret);
_bool GetArgInt (const _int& arg, _int &ret);
_bool GetArgLong (const _int& arg, _long &ret);
_bool GetArgUnsignedShort (const _int& arg, _ushort &ret);
_bool GetArgUnsignedInt (const _int& arg, _uint &ret);
_bool GetArgUnsignedLong (const _int& arg, _ulong &ret);
_bool GetArgFloat (const _int& arg, float &ret);
_bool GetArgDouble (const _int& arg, double &ret);
bool GetArgString (const int& arg, std::string &ret);
bool GetArgBool (const int& arg, bool &ret);
bool GetArgChar (const int& arg, char &ret);
bool GetArgShort (const int& arg, short &ret);
bool GetArgInt (const int& arg, int &ret);
bool GetArgLong (const int& arg, long &ret);
bool GetArgUnsignedShort (const int& arg, unsigned short &ret);
bool GetArgUnsignedInt (const int& arg, unsigned int &ret);
bool GetArgUnsignedLong (const int& arg, unsigned long &ret);
bool GetArgFloat (const int& arg, float &ret);
bool GetArgDouble (const int& arg, double &ret);
// Get Argument count
size_t GetArgCount() const { return m_Arguments.size(); }
@ -210,7 +210,7 @@ public:
std::vector<CParserTaskType> m_TaskTypes;
// Interface
_bool InputTaskType(const std::string& strName, const std::string& strSyntax);
bool InputTaskType(const std::string& strName, const std::string& strSyntax);
};

View File

@ -2,6 +2,8 @@
// Globals
int g_xres = 800, g_yres = 600;
int g_bpp = 32;
int g_freq = 60;
DEFINE_ERROR(PS_OK, "OK");
DEFINE_ERROR(PS_FAIL, "Fail");

View File

@ -9,8 +9,6 @@ Standard declarations which are included in all projects.
#ifndef PROMETHEUS_H
#define PROMETHEUS_H
#pragma warning (disable : 4786) // VC6 template warning spew
#pragma warning (disable : 4291)
#include <stdio.h>
#include <math.h>
@ -19,33 +17,10 @@ Standard declarations which are included in all projects.
// Globals
extern int g_xres, g_yres;
extern int g_bpp;
extern int g_freq;
// Standard typedefs
typedef int _int;
typedef unsigned int _unsigned_int;
typedef long _long;
typedef unsigned long _unsigned_long;
typedef bool _bool;
typedef char _char;
typedef unsigned char _unsigned_char;
typedef char _byte;
typedef unsigned char _unsigned_byte;
typedef float _float;
typedef double _double;
typedef unsigned short _unsigned_short;
typedef unsigned short _ushort;
typedef short _short;
typedef unsigned long _ulong;
typedef unsigned int _uint;
// Error handling
typedef const char * PS_RESULT;