#include "StdAfx.h"
#include "UIDlgBuilder.h"
/////////////////////////////////////////////////////////////////////////////////////
CStdPtrArray::CStdPtrArray(int iPreallocSize) : m_ppVoid(NULL), m_nCount(0), m_nAllocated(iPreallocSize)
{
ASSERT(iPreallocSize>=0);
if( iPreallocSize > 0 ) m_ppVoid = static_cast<LPVOID*>(malloc(iPreallocSize * sizeof(LPVOID)));
}
CStdPtrArray::~CStdPtrArray()
{
if( m_ppVoid != NULL ) free(m_ppVoid);
}
void CStdPtrArray::Empty()
{
if( m_ppVoid != NULL ) free(m_ppVoid);
m_ppVoid = NULL;
m_nCount = m_nAllocated = 0;
}
void CStdPtrArray::Resize(int iSize)
{
Empty();
m_ppVoid = static_cast<LPVOID*>(malloc(iSize * sizeof(LPVOID)));
::ZeroMemory(m_ppVoid, iSize * sizeof(LPVOID));
m_nAllocated = iSize;
m_nCount = iSize;
}
bool CStdPtrArray::IsEmpty() const
{
return m_nCount == 0;
}
bool CStdPtrArray::Add(LPVOID pData)
{
if( ++m_nCount >= m_nAllocated) {
m_nAllocated *= 2;
if( m_nAllocated == 0 ) m_nAllocated = 11;
m_ppVoid = static_cast<LPVOID*>(realloc(m_ppVoid, m_nAllocated * sizeof(LPVOID)));
if( m_ppVoid == NULL ) return false;
}
m_ppVoid[m_nCount - 1] = pData;
return true;
}
bool CStdPtrArray::InsertAt(int iIndex, LPVOID pData)
{
if( iIndex == m_nCount ) return Add(pData);
if( iIndex < 0 || iIndex > m_nCount ) return false;
if( ++m_nCount >= m_nAllocated) {
m_nAllocated *= 2;
if( m_nAllocated == 0 ) m_nAllocated = 11;
m_ppVoid = static_cast<LPVOID*>(realloc(m_ppVoid, m_nAllocated * sizeof(LPVOID)));
if( m_ppVoid == NULL ) return false;
}
memmove(&m_ppVoid[iIndex + 1], &m_ppVoid[iIndex], (m_nCount - iIndex - 1) * sizeof(LPVOID));
m_ppVoid[iIndex] = pData;
return true;
}
bool CStdPtrArray::SetAt(int iIndex, LPVOID pData)
{
if( iIndex < 0 || iIndex >= m_nCount ) return false;
m_ppVoid[iIndex] = pData;
return true;
}
bool CStdPtrArray::Remove(int iIndex)
{
if( iIndex < 0 || iIndex >= m_nCount ) return false;
if( iIndex < --m_nCount ) ::CopyMemory(m_ppVoid + iIndex, m_ppVoid + iIndex + 1, (m_nCount - iIndex) * sizeof(LPVOID));
return true;
}
int CStdPtrArray::Find(LPVOID pData) const
{
for( int i = 0; i < m_nCount; i++ ) if( m_ppVoid[i] == pData ) return i;
return -1;
}
int CStdPtrArray::GetSize() const
{
return m_nCount;
}
LPVOID* CStdPtrArray::GetData()
{
return m_ppVoid;
}
LPVOID CStdPtrArray::GetAt(int iIndex) const
{
if( iIndex < 0 || iIndex >= m_nCount ) return NULL;
return m_ppVoid[iIndex];
}
LPVOID CStdPtrArray::operator[] (int iIndex) const
{
ASSERT(iIndex>=0 && iIndex<m_nCount);
return m_ppVoid[iIndex];
}
/////////////////////////////////////////////////////////////////////////////////////
//
//
CStdString::CStdString() : m_pstr(m_szBuffer)
{
m_szBuffer[0] = '\0';
}
CStdString::CStdString(const TCHAR ch) : m_pstr(m_szBuffer)
{
m_szBuffer[0] = ch;
m_szBuffer[1] = '\0';
}
CStdString::CStdString(LPCTSTR lpsz, int nLen) : m_pstr(m_szBuffer)
{
ASSERT(!::IsBadStringPtr(lpsz,-1) || lpsz==NULL);
Assign(lpsz, nLen);
}
CStdString::CStdString(const CStdString& src) : m_pstr(m_szBuffer)
{
Assign(src.m_pstr);
}
CStdString::~CStdString()
{
if( m_pstr != m_szBuffer ) free(m_pstr);
}
int CStdString::GetLength() const
{
return (int) _tcslen(m_pstr);
}
CStdString::operator LPCTSTR() const
{
return m_pstr;
}
void CStdString::Append(LPCTSTR pstr)
{
int nNewLength = GetLength() + (int) _tcslen(pstr);
if( nNewLength >= MAX_LOCAL_STRING_LEN ) {
if( m_pstr == m_szBuffer ) {
m_pstr = static_cast<LPTSTR>(malloc((nNewLength + 1) * sizeof(TCHAR)));
_tcscpy(m_pstr, m_szBuffer);
_tcscat(m_pstr, pstr);
}
else {
m_pstr = static_cast<LPTSTR>(realloc(m_pstr, (nNewLength + 1) * sizeof(TCHAR)));
_tcscat(m_pstr, pstr);
}
}
else {
if( m_pstr != m_szBuffer ) {
free(m_pstr);
m_pstr = m_szBuffer;
}
_tcscat(m_szBuffer, pstr);
}
}
void CStdString::Assign(LPCTSTR pstr, int cchMax)
{
if( pstr == NULL ) pstr = _T("");
cchMax = (cchMax < 0 ? (int) _tcslen(pstr) : cchMax);
if( cchMax < MAX_LOCAL_STRING_LEN ) {
if( m_pstr != m_szBuffer ) {
free(m_pstr);
m_pstr = m_szBuffer;
}
}
else if( cchMax > GetLength() || m_pstr == m_szBuffer ) {
if( m_pstr == m_szBuffer ) m_pstr = NULL;
m_pstr = static_cast<LPTSTR>(realloc(m_pstr, (cchMax + 1) * sizeof(TCHAR)));
}
_tcsncpy(m_pstr, pstr, cchMax);
m_pstr[cchMax] = '\0';
}
bool CStdString::IsEmpty() const
{
return m_pstr[0] == '\0';
}
void CStdString::Empty()
{
if( m_pstr != m_szBuffer ) free(m_pstr);
m_pstr = m_szBuffer;
m_szBuffer[0] = '\0';
}
LPCTSTR CStdString::GetData()
{
return m_pstr;
}
TCHAR CStdString::GetAt(int nIndex) const
{
return m_pstr[nIndex];
}
TCHAR CStdString::operator[] (int nIndex) const
{
return m_pstr[nIndex];
}
const CStdString& CStdString::operator=(const CStdString& src)
{
Assign(src);
return *this;
}
const CStdString& CStdString::operator=(LPCTSTR lpStr)
{
ASSERT(!::IsBadStringPtr(lpStr,-1));
Assign(lpStr);
return *this;
}
#ifndef _UNICODE
const CStdString& CStdString::operator=(LPCWSTR lpwStr)
{
ASSERT(!::IsBadStringPtrW(lpwStr,-1));
int cchStr = ((int) wcslen(lpwStr) * 2) + 1;
LPSTR pstr = (LPSTR) _alloca(cchStr);
if( pstr != NULL ) ::WideCharToMultiByte(::GetACP(), 0, lpwStr, -1, pstr, cchStr, NULL, NULL);
Assign(pstr);
return *this;
}
#endif // _UNICODE
const CStdString& CStdString::operator=(const TCHAR ch)
{
Empty();
m_szBuffer[0] = ch;
m_szBuffer[1] = '\0';
return *this;
}
CStdString CStdString::operator+(const CStdString& src)
{
Append(src);
return *this;
}
CStdString CStdString::operator+(LPCTSTR lpStr)
{
ASSERT(!::IsBadStringPtr(lpStr,-1));
Append(lpStr);
return *this;
}
const CStdString& CStdString::operator+=(const CStdString& src)
{
Append(src);
return *this;
}
const CStdString& CStdString::operator+=(LPCTSTR lpStr)
{
ASSERT(!::IsBadStringPtr(lpStr,-1));
Append(lpStr);
return *this;
}
const CStdString& CStdString::operator+=(const TCHAR ch)
{
TCHAR str[] = { ch, '\0' };
Append(str);
return *this;
}
bool CStdString::operator == (LPCTSTR str) const { return (Compare(str) == 0); };
bool CStdString::operator != (LPCTSTR str) const { return (Compare(str) != 0); };
bool CStdString::operator <= (LPCTSTR str) const { return (Compare(str) <= 0); };
bool CStdString::operator < (LPCTSTR str) const { return (Compare(str) < 0); };
bool CStdString::operator >= (LPCTSTR str) const { return (Compare(str) >= 0); };
bool CStdString::operator > (LPCTSTR str) const { return (Compare(str) > 0); };
void CStdString::SetAt(int nIndex, TCHAR ch)
{
ASSERT(nIndex>=0 && nIndex<GetLength());
m_pstr[nIndex] = ch;
}
int CStdString::Compare(LPCTSTR lpsz) const
{
return _tcscmp(m_pstr, lpsz);
}
int CStdString::CompareNoCase(LPCTSTR lpsz) const
{
return _tcsicmp(m_pstr, lpsz);
}
void CStdString::MakeUpper()
{
_tcsupr(m_pstr);
}
void CStdString::MakeLower()
{
_tcslwr(m_pstr);
}
CStdString CStdString::Left(int iLength) const
{
if( iLength < 0 ) iLength = 0;
if( iLength > GetLength() ) iLength = GetLength();
return CStdString(m_pstr, iLength);
}
CStdString CStdString::Mid(int iPos, int iLength) const
{
if( iLength < 0 ) iLength = GetLength() - iPos;
if( iPos + iLength > GetLength() ) iLength = GetLength() - iPos;
if( iLength <= 0 ) return CStdString();
return CStdString(m_pstr + iPos, iLength);
}
CStdString CStdString::Right(int iLength) const
{
int iPos = GetLength() - iLength;
if( iPos < 0 ) {
iPos = 0;
iLength = GetLength();
}
return CStdString(m_pstr + iPos, iLength);
}
int CStdString::Find(TCHAR ch, int iPos /*= 0*/) const
{
ASSERT(iPos>=0 && iPos<=GetLength());
if( iPos != 0 && (iPos <
启舰
- 粉丝: 4w+
- 资源: 197
最新资源
- 三相逆变 单相 三相逆变器 SPWM -stm32主控(输入、输出具体可根据需要设定),本逆变器可以二次开发 本内容只包括 逆变程序,实现变频(0~100Hz)、变压调节,均有外接按键控制(使用
- 长焊缝打磨机step全套技术资料100%好用.zip
- Chapter 03 复合数据类型-2(资源)
- Web电影票系统:数据库设计与数据管理
- 震荡输送线sw18全套技术资料100%好用.zip
- 毕业的时候无聊写了一个报价系统,只用了前端,后端和数据库没写
- 奶茶店客户服务:网上系统支持模块
- 真空负压站sw16可编辑全套技术资料100%好用.zip
- 花店e时代:Java Web环境下的系统设计与优化
- z20241226dad
- ECharts旭日图-MonochromeSunburst.zip
- ECharts旭日图-BookRecords.rar
- ECharts旭日图-DrinkFlavors.zip
- ECharts旭日图-基础旭日图.zip
- ECharts旭日图-旭日图标签旋转.rar
- ECharts旭日图-旭日图使用视觉编码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈