Updated AMXX Template Library
This commit is contained in:
parent
7f255b2b7f
commit
1efbb0f65e
|
@ -1,3 +1,34 @@
|
||||||
|
/* AMX Mod X
|
||||||
|
*
|
||||||
|
* by the AMX Mod X Development Team
|
||||||
|
* originally developed by OLO
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the author gives permission to
|
||||||
|
* link the code of this program with the Half-Life Game Engine ("HL
|
||||||
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||||
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||||
|
* respects for all of the code used other than the HL Engine and MODs
|
||||||
|
* from Valve. If you modify this file, you may extend this exception
|
||||||
|
* to your version of the file, but you are not obligated to do so. If
|
||||||
|
* you do not wish to do so, delete this exception statement from your
|
||||||
|
* version.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _INCLUDE_CSTRING_H
|
#ifndef _INCLUDE_CSTRING_H
|
||||||
#define _INCLUDE_CSTRING_H
|
#define _INCLUDE_CSTRING_H
|
||||||
|
|
||||||
|
@ -8,7 +39,12 @@ public:
|
||||||
CString() { v = NULL; mSize = 0; }
|
CString() { v = NULL; mSize = 0; }
|
||||||
~CString() { if (v) delete [] v; }
|
~CString() { if (v) delete [] v; }
|
||||||
|
|
||||||
|
//added these for amxx
|
||||||
|
CString(const char *src) { v = NULL; mSize = 0; assign(src); }
|
||||||
|
CString(CString &src) { v = NULL; mSize = 0; assign(src.c_str()); }
|
||||||
|
|
||||||
const char *c_str() { return v?v:""; }
|
const char *c_str() { return v?v:""; }
|
||||||
|
const char *c_str() const { return v?v:""; }
|
||||||
|
|
||||||
void append(const char *t)
|
void append(const char *t)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +97,15 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Added this for amxx inclusion
|
||||||
|
bool empty()
|
||||||
|
{
|
||||||
|
if (!v || !mSize)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int size()
|
int size()
|
||||||
{
|
{
|
||||||
if (!v)
|
if (!v)
|
||||||
|
|
|
@ -76,7 +76,7 @@ template <class T> class CVector
|
||||||
delete [] m_Data;
|
delete [] m_Data;
|
||||||
}
|
}
|
||||||
if (m_Size < size)
|
if (m_Size < size)
|
||||||
m_CurrentUsedSize = size;
|
m_CurrentSize = size;
|
||||||
m_Data = newData;
|
m_Data = newData;
|
||||||
m_Size = size;
|
m_Size = size;
|
||||||
return true;
|
return true;
|
||||||
|
@ -90,6 +90,7 @@ protected:
|
||||||
T *m_Data;
|
T *m_Data;
|
||||||
size_t m_Size;
|
size_t m_Size;
|
||||||
size_t m_CurrentUsedSize;
|
size_t m_CurrentUsedSize;
|
||||||
|
size_t m_CurrentSize;
|
||||||
public:
|
public:
|
||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
|
@ -397,7 +398,7 @@ public:
|
||||||
if (where != m_Data)
|
if (where != m_Data)
|
||||||
--where;
|
--where;
|
||||||
// validate iter
|
// validate iter
|
||||||
if (where < m_Data || where >= (m_Data + m_CurrentSize))
|
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
++m_CurrentUsedSize;
|
++m_CurrentUsedSize;
|
||||||
|
@ -415,7 +416,7 @@ public:
|
||||||
void erase(iterator where)
|
void erase(iterator where)
|
||||||
{
|
{
|
||||||
// validate iter
|
// validate iter
|
||||||
if (where < m_Data || where >= (m_Data + m_CurrentSize))
|
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_CurrentUsedSize > 1)
|
if (m_CurrentUsedSize > 1)
|
||||||
|
@ -438,3 +439,4 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __CVECTOR_H__
|
#endif // __CVECTOR_H__
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user