亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? spstring.cpp

?? 股票軟件
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
/*
	Cross Platform Core Code.

	Copyright(R) 2001-2002 Balang Software.
	All rights reserved.

	Using:
		class	CSPString;
*/
#include	"StdAfx.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#ifdef	_DEBUG
#define	new	DEBUG_NEW
#endif

#ifndef	_SP_ENABLE_INLINES
#define	_SPSTRING_INLINE
#include "SpString.inl"
#undef	_SPSTRING_INLINE
#endif

/////////////////////////////////////////////////////////////////////////////
// static class data, special inlines

// afxSPChNil is left for backward compatibility
TCHAR afxSPChNil = '\0';

// For an empty string, m_pchData will point here
// (note: avoids special case of checking for NULL m_pchData)
// empty string data (and locked)
int _afxSPInitData[] = { -1, 0, 0, 0 };
CSPStringData* _afxSPDataNil = (CSPStringData*)&_afxSPInitData;
LPCTSTR _afxSPPchNil = (LPCTSTR)(((BYTE*)&_afxSPInitData)+sizeof(CSPStringData));
// special function to make afxEmptyString work even during initialization
const CSPString& __stdcall AfxGetEmptySPString()
	{ return *(CSPString*)&_afxSPPchNil; }

//////////////////////////////////////////////////////////////////////////////
// Construction/Destruction

#ifdef _AFXDLL
CSPString::CSPString()
{
	Init();
}
#endif

CSPString::CSPString(const CSPString& stringSrc)
{
	SP_ASSERT(stringSrc.GetData()->nRefs != 0);
	if (stringSrc.GetData()->nRefs >= 0)
	{
		SP_ASSERT(stringSrc.GetData() != _afxSPDataNil);
		m_pchData = stringSrc.m_pchData;
		InterlockedIncrement(&GetData()->nRefs);
	}
	else
	{
		Init();
		*this = stringSrc.m_pchData;
	}
}

void CSPString::AllocBuffer(int nLen)
// always allocate one extra character for '\0' termination
// assumes [optimistically] that data length will equal allocation length
{
	SP_ASSERT(nLen >= 0);
	SP_ASSERT(nLen <= INT_MAX-1);    // max size (enough room for 1 extra)

	if (nLen == 0)
		Init();
	else
	{
		CSPStringData* pData;
		{
			pData = (CSPStringData*)
				new BYTE[sizeof(CSPStringData) + (nLen+1)*sizeof(TCHAR)];
			pData->nAllocLength = nLen;
		}
		pData->nRefs = 1;
		pData->data()[nLen] = '\0';
		pData->nDataLength = nLen;
		m_pchData = pData->data();
	}
}

void __fastcall CSPString::FreeData(CSPStringData* pData)
{
	delete[] (BYTE*)pData;
}

void CSPString::Release()
{
	if (GetData() != _afxSPDataNil)
	{
		SP_ASSERT(GetData()->nRefs != 0);
		if (InterlockedDecrement(&GetData()->nRefs) <= 0)
			FreeData(GetData());
		Init();
	}
}

void PASCAL CSPString::Release(CSPStringData* pData)
{
	if (pData != _afxSPDataNil)
	{
		SP_ASSERT(pData->nRefs != 0);
		if (InterlockedDecrement(&pData->nRefs) <= 0)
			FreeData(pData);
	}
}

void CSPString::Empty()
{
	if (GetData()->nDataLength == 0)
		return;
	if (GetData()->nRefs >= 0)
		Release();
	else
		*this = &afxSPChNil;
	SP_ASSERT(GetData()->nDataLength == 0);
	SP_ASSERT(GetData()->nRefs < 0 || GetData()->nAllocLength == 0);
}

void CSPString::CopyBeforeWrite()
{
	if (GetData()->nRefs > 1)
	{
		CSPStringData* pData = GetData();
		Release();
		AllocBuffer(pData->nDataLength);
		memcpy(m_pchData, pData->data(), (pData->nDataLength+1)*sizeof(TCHAR));
	}
	SP_ASSERT(GetData()->nRefs <= 1);
}

void CSPString::AllocBeforeWrite(int nLen)
{
	if (GetData()->nRefs > 1 || nLen > GetData()->nAllocLength)
	{
		Release();
		AllocBuffer(nLen);
	}
	SP_ASSERT(GetData()->nRefs <= 1);
}

CSPString::~CSPString()
//  free any attached data
{
	if (GetData() != _afxSPDataNil)
	{
		if (InterlockedDecrement(&GetData()->nRefs) <= 0)
			FreeData(GetData());
	}
}

//////////////////////////////////////////////////////////////////////////////
// Helpers for the rest of the implementation

void CSPString::AllocCopy(CSPString& dest, int nCopyLen, int nCopyIndex,
	 int nExtraLen) const
{
	// will clone the data attached to this string
	// allocating 'nExtraLen' characters
	// Places results in uninitialized string 'dest'
	// Will copy the part or all of original data to start of new string

	int nNewLen = nCopyLen + nExtraLen;
	if (nNewLen == 0)
	{
		dest.Init();
	}
	else
	{
		dest.AllocBuffer(nNewLen);
		memcpy(dest.m_pchData, m_pchData+nCopyIndex, nCopyLen*sizeof(TCHAR));
	}
}

//////////////////////////////////////////////////////////////////////////////
// More sophisticated construction

CSPString::CSPString(LPCTSTR lpsz)
{
	Init();
	if (lpsz != NULL && HIWORD(lpsz) == NULL)
	{
		UINT nID = LOWORD((DWORD)lpsz);
		if (!LoadString(nID))
			SP_TRACE1("Warning: implicit LoadString(%u) failed\n", nID);
	}
	else
	{
		int nLen = SafeStrlen(lpsz);
		if (nLen != 0)
		{
			AllocBuffer(nLen);
			memcpy(m_pchData, lpsz, nLen*sizeof(TCHAR));
		}
	}
}

/////////////////////////////////////////////////////////////////////////////
// Special conversion constructors

#ifdef _UNICODE
CSPString::CSPString(LPCSTR lpsz)
{
	Init();
	int nSrcLen = lpsz != NULL ? lstrlenA(lpsz) : 0;
	if (nSrcLen != 0)
	{
		AllocBuffer(nSrcLen);
		mbstowcs(m_pchData, lpsz, nSrcLen+1);
		ReleaseBuffer();
	}
}
#else //_UNICODE
CSPString::CSPString(LPCWSTR lpsz)
{
	Init();
	int nSrcLen = lpsz != NULL ? wcslen(lpsz) : 0;
	if (nSrcLen != 0)
	{
		AllocBuffer(nSrcLen*2);
		wcstombs(m_pchData, lpsz, (nSrcLen*2)+1);
		ReleaseBuffer();
	}
}
#endif //!_UNICODE

//////////////////////////////////////////////////////////////////////////////
// Assignment operators
//  All assign a new value to the string
//      (a) first see if the buffer is big enough
//      (b) if enough room, copy on top of old buffer, set size and type
//      (c) otherwise free old string data, and create a new one
//
//  All routines return the new string (but as a 'const CSPString&' so that
//      assigning it again will cause a copy, eg: s1 = s2 = "hi there".
//

void CSPString::AssignCopy(int nSrcLen, LPCTSTR lpszSrcData)
{
	AllocBeforeWrite(nSrcLen);
	memcpy(m_pchData, lpszSrcData, nSrcLen*sizeof(TCHAR));
	GetData()->nDataLength = nSrcLen;
	m_pchData[nSrcLen] = '\0';
}

const CSPString& CSPString::operator=(const CSPString& stringSrc)
{
	if (m_pchData != stringSrc.m_pchData)
	{
		if ((GetData()->nRefs < 0 && GetData() != _afxSPDataNil) ||
			stringSrc.GetData()->nRefs < 0)
		{
			// actual copy necessary since one of the strings is locked
			AssignCopy(stringSrc.GetData()->nDataLength, stringSrc.m_pchData);
		}
		else
		{
			// can just copy references around
			Release();
			SP_ASSERT(stringSrc.GetData() != _afxSPDataNil);
			m_pchData = stringSrc.m_pchData;
			InterlockedIncrement(&GetData()->nRefs);
		}
	}
	return *this;
}

const CSPString& CSPString::operator=(LPCTSTR lpsz)
{
	SP_ASSERT(lpsz == NULL || SP_IsValidString(lpsz));
	AssignCopy(SafeStrlen(lpsz), lpsz);
	return *this;
}

/////////////////////////////////////////////////////////////////////////////
// Special conversion assignment

#ifdef _UNICODE
const CSPString& CSPString::operator=(LPCSTR lpsz)
{
	int nSrcLen = lpsz != NULL ? lstrlenA(lpsz) : 0;
	AllocBeforeWrite(nSrcLen);
	mbstowcs(m_pchData, lpsz, nSrcLen+1);
	ReleaseBuffer();
	return *this;
}
#else //!_UNICODE
const CSPString& CSPString::operator=(LPCWSTR lpsz)
{
	int nSrcLen = lpsz != NULL ? wcslen(lpsz) : 0;
	AllocBeforeWrite(nSrcLen*2);
	wcstombs(m_pchData, lpsz, (nSrcLen*2)+1);
	ReleaseBuffer();
	return *this;
}
#endif  //!_UNICODE

//////////////////////////////////////////////////////////////////////////////
// concatenation

// NOTE: "operator+" is done as friend functions for simplicity
//      There are three variants:
//          CSPString + CSPString
// and for ? = TCHAR, LPCTSTR
//          CSPString + ?
//          ? + CSPString

void CSPString::ConcatCopy(int nSrc1Len, LPCTSTR lpszSrc1Data,
	int nSrc2Len, LPCTSTR lpszSrc2Data)
{
  // -- master concatenation routine
  // Concatenate two sources
  // -- assume that 'this' is a new CSPString object

	int nNewLen = nSrc1Len + nSrc2Len;
	if (nNewLen != 0)
	{
		AllocBuffer(nNewLen);
		memcpy(m_pchData, lpszSrc1Data, nSrc1Len*sizeof(TCHAR));
		memcpy(m_pchData+nSrc1Len, lpszSrc2Data, nSrc2Len*sizeof(TCHAR));
	}
}

CSPString __stdcall operator+(const CSPString& string1, const CSPString& string2)
{
	CSPString s;
	s.ConcatCopy(string1.GetData()->nDataLength, string1.m_pchData,
		string2.GetData()->nDataLength, string2.m_pchData);
	return s;
}

CSPString __stdcall operator+(const CSPString& string, LPCTSTR lpsz)
{
	SP_ASSERT(lpsz == NULL || SP_IsValidString(lpsz));
	CSPString s;
	s.ConcatCopy(string.GetData()->nDataLength, string.m_pchData,
		CSPString::SafeStrlen(lpsz), lpsz);
	return s;
}

CSPString __stdcall operator+(LPCTSTR lpsz, const CSPString& string)
{
	SP_ASSERT(lpsz == NULL || SP_IsValidString(lpsz));
	CSPString s;
	s.ConcatCopy(CSPString::SafeStrlen(lpsz), lpsz, string.GetData()->nDataLength,
		string.m_pchData);
	return s;
}

//////////////////////////////////////////////////////////////////////////////
// concatenate in place

void CSPString::ConcatInPlace(int nSrcLen, LPCTSTR lpszSrcData)
{
	//  -- the main routine for += operators

	// concatenating an empty string is a no-op!
	if (nSrcLen == 0)
		return;

	// if the buffer is too small, or we have a width mis-match, just
	//   allocate a new buffer (slow but sure)
	if (GetData()->nRefs > 1 || GetData()->nDataLength + nSrcLen > GetData()->nAllocLength)
	{
		// we have to grow the buffer, use the ConcatCopy routine
		CSPStringData* pOldData = GetData();
		ConcatCopy(GetData()->nDataLength, m_pchData, nSrcLen, lpszSrcData);
		SP_ASSERT(pOldData != NULL);
		CSPString::Release(pOldData);
	}
	else
	{
		// fast concatenation when buffer big enough
		memcpy(m_pchData+GetData()->nDataLength, lpszSrcData, nSrcLen*sizeof(TCHAR));
		GetData()->nDataLength += nSrcLen;
		SP_ASSERT(GetData()->nDataLength <= GetData()->nAllocLength);
		m_pchData[GetData()->nDataLength] = '\0';
	}
}

const CSPString& CSPString::operator+=(LPCTSTR lpsz)
{
	SP_ASSERT(lpsz == NULL || SP_IsValidString(lpsz));
	ConcatInPlace(SafeStrlen(lpsz), lpsz);
	return *this;
}

const CSPString& CSPString::operator+=(TCHAR ch)
{
	ConcatInPlace(1, &ch);
	return *this;
}

const CSPString& CSPString::operator+=(const CSPString& string)
{
	ConcatInPlace(string.GetData()->nDataLength, string.m_pchData);
	return *this;
}

///////////////////////////////////////////////////////////////////////////////
// Advanced direct buffer access

LPTSTR CSPString::GetBuffer(int nMinBufLength)
{
	SP_ASSERT(nMinBufLength >= 0);

	if (GetData()->nRefs > 1 || nMinBufLength > GetData()->nAllocLength)
	{
#ifdef _DEBUG
		// give a warning in case locked string becomes unlocked
		if (GetData() != _afxSPDataNil && GetData()->nRefs < 0)
			SP_TRACE0("Warning: GetBuffer on locked CSPString creates unlocked CSPString!\n");
#endif
		// we have to grow the buffer
		CSPStringData* pOldData = GetData();
		int nOldLen = GetData()->nDataLength;   // AllocBuffer will tromp it
		if (nMinBufLength < nOldLen)
			nMinBufLength = nOldLen;
		AllocBuffer(nMinBufLength);
		memcpy(m_pchData, pOldData->data(), (nOldLen+1)*sizeof(TCHAR));
		GetData()->nDataLength = nOldLen;
		CSPString::Release(pOldData);
	}
	SP_ASSERT(GetData()->nRefs <= 1);

	// return a pointer to the character storage for this string
	SP_ASSERT(m_pchData != NULL);
	return m_pchData;
}

void CSPString::ReleaseBuffer(int nNewLength)
{
	CopyBeforeWrite();  // just in case GetBuffer was not called

	if (nNewLength == -1)
		nNewLength = lstrlen(m_pchData); // zero terminated

	SP_ASSERT(nNewLength <= GetData()->nAllocLength);
	GetData()->nDataLength = nNewLength;
	m_pchData[nNewLength] = '\0';
}

LPTSTR CSPString::GetBufferSetLength(int nNewLength)
{
	SP_ASSERT(nNewLength >= 0);

	GetBuffer(nNewLength);
	GetData()->nDataLength = nNewLength;
	m_pchData[nNewLength] = '\0';
	return m_pchData;
}

void CSPString::FreeExtra()
{
	SP_ASSERT(GetData()->nDataLength <= GetData()->nAllocLength);
	if (GetData()->nDataLength != GetData()->nAllocLength)
	{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线视频国内一区二区| 欧美精品一区二区不卡 | 日本高清不卡一区| 欧美一区二区三区免费在线看| 欧美不卡视频一区| 亚洲激情六月丁香| 国产自产视频一区二区三区| 欧洲人成人精品| 国产精品视频一二| 蜜臀精品一区二区三区在线观看| 成人激情电影免费在线观看| 欧美成人a∨高清免费观看| 一区二区三区不卡视频在线观看 | 国产精品18久久久久久久久| 欧美中文字幕一区二区三区| 久久精品这里都是精品| 午夜精品影院在线观看| 色呦呦日韩精品| 国产精品卡一卡二卡三| 国产精品资源在线看| 91精品中文字幕一区二区三区| 又紧又大又爽精品一区二区| 成人精品gif动图一区| 欧美不卡一区二区三区| 蜜臀av一级做a爰片久久| 8x8x8国产精品| 婷婷开心激情综合| 欧美久久一二区| 午夜精品一区二区三区免费视频| 欧美日韩精品二区第二页| 亚洲一区二区三区三| 91久久奴性调教| 亚洲一区中文日韩| 精品视频一区二区不卡| 亚洲综合免费观看高清在线观看| 91黄色激情网站| 亚洲国产裸拍裸体视频在线观看乱了 | 国产精品白丝jk白祙喷水网站| 精品sm在线观看| 国产精一区二区三区| 久久九九99视频| 99这里只有久久精品视频| 国产精品美女久久久久久久久久久| 成人开心网精品视频| 亚洲日本中文字幕区| 色婷婷综合久久久| 亚洲成人免费看| 91精品国产综合久久婷婷香蕉| 丝袜美腿高跟呻吟高潮一区| 欧美一区二区视频在线观看2020| 久久精品国产999大香线蕉| 精品88久久久久88久久久| 成人妖精视频yjsp地址| 香蕉久久一区二区不卡无毒影院| 一本到不卡精品视频在线观看| 亚洲国产色一区| 久久综合狠狠综合| 91麻豆精品在线观看| 舔着乳尖日韩一区| 久久亚洲一级片| 在线观看一区二区视频| 免费看黄色91| 国产精品久久久久影院色老大| 欧美日韩免费一区二区三区| 久久精品国产在热久久| 国产精品女主播在线观看| 欧美午夜精品免费| 精品在线免费视频| 一区二区三区波多野结衣在线观看| 91精品国产品国语在线不卡| 国产不卡在线一区| 亚洲va在线va天堂| 国产精品电影院| 日韩欧美一级片| 在线观看一区二区视频| 国产黄人亚洲片| 日韩精品欧美精品| 中文字幕av不卡| 日韩限制级电影在线观看| 成人不卡免费av| 久久国产成人午夜av影院| 亚洲日本青草视频在线怡红院| 欧美一区二区三区四区在线观看| 不卡在线观看av| 国内精品久久久久影院色| 婷婷中文字幕综合| 亚洲精品视频在线观看免费| 久久尤物电影视频在线观看| 欧美日韩色综合| 91福利在线免费观看| 成人性色生活片免费看爆迷你毛片| 日韩精品乱码av一区二区| 国产精品夫妻自拍| 国产人成一区二区三区影院| 欧美电视剧免费全集观看| 欧美日韩一区二区三区在线看| 99久久精品一区| 成人中文字幕在线| 狠狠色丁香久久婷婷综合丁香| 午夜av一区二区| 亚洲综合偷拍欧美一区色| 亚洲三级免费观看| 亚洲视频在线一区| 最新高清无码专区| 成人欧美一区二区三区小说 | 欧美一级高清片| 欧美日韩国产影片| 欧美三级资源在线| 在线观看视频一区| 日本道免费精品一区二区三区| 北条麻妃国产九九精品视频| 国产91丝袜在线播放| 国产一区美女在线| 国产永久精品大片wwwapp| 久久99热这里只有精品| 蜜臀a∨国产成人精品| 欧美aa在线视频| 激情综合色播五月| 国内不卡的二区三区中文字幕| 麻豆国产精品官网| 精品一区免费av| 国产福利不卡视频| 成人黄色在线看| 色综合久久精品| 欧美优质美女网站| 欧美男生操女生| 亚洲精品在线三区| 久久网这里都是精品| 欧美激情一区三区| 亚洲最大成人网4388xx| 亚洲综合激情网| 麻豆freexxxx性91精品| 国产精品亚洲午夜一区二区三区 | 麻豆91在线观看| 国产精品系列在线观看| 97成人超碰视| 欧美日韩国产影片| 久久久久久久久岛国免费| 中文字幕高清不卡| 午夜精品在线看| 国产成人在线色| 91麻豆免费看| 精品少妇一区二区三区 | 亚洲综合图片区| 久久精品国产亚洲一区二区三区| 国产一区二区三区av电影| 91香蕉视频污在线| 日韩视频一区二区三区在线播放| 国产午夜亚洲精品午夜鲁丝片| 亚洲欧美怡红院| 免费日韩伦理电影| www.日韩精品| 日韩欧美综合一区| 亚洲欧美日韩国产另类专区| 首页国产欧美日韩丝袜| 国产91精品在线观看| 欧美高清视频www夜色资源网| 国产欧美日韩精品一区| 亚洲国产综合视频在线观看| 黄页网站大全一区二区| 色八戒一区二区三区| 久久五月婷婷丁香社区| 偷拍一区二区三区四区| 成人av资源下载| 欧美一二三在线| 亚洲精品ww久久久久久p站| 久久国产综合精品| 欧美亚洲图片小说| 欧美激情一区二区三区蜜桃视频 | 欧美一区二区福利在线| 一区在线播放视频| 国产精品1024久久| 欧美电影免费观看高清完整版在线| 亚洲男帅同性gay1069| 国产成人一区二区精品非洲| 91麻豆精品国产91久久久| 亚洲精品成人a在线观看| 成人短视频下载| 久久综合色婷婷| 三级精品在线观看| 欧美在线视频全部完| 国产精品久久久久久久久久免费看| 久久国产精品第一页| 91传媒视频在线播放| 国产精品久久久久久久久晋中| 国产精品一区二区久激情瑜伽| 日韩一区二区三区四区| 午夜视频久久久久久| 欧美性猛交xxxx黑人交| 亚洲精品视频免费观看| 99国产精品一区| 国产精品视频免费| 成人做爰69片免费看网站| 久久精品一区四区| 国产成人av在线影院| 国产午夜亚洲精品午夜鲁丝片 | 高清国产一区二区三区| 久久亚洲免费视频| 国产精品中文字幕欧美| 国产亚洲精品aa午夜观看|