亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产一区福利在线| 日韩欧美123| 亚洲欧美日本韩国| 国产成人免费视频| 中文字幕免费不卡| 99re这里都是精品| 亚洲v中文字幕| 欧美一级电影网站| 蜜桃一区二区三区四区| 亚洲欧美精品午睡沙发| 久久国产夜色精品鲁鲁99| 欧美老女人第四色| 美女尤物国产一区| 国产欧美精品一区二区色综合朱莉| 成人国产精品免费观看动漫| 亚洲精品亚洲人成人网 | 午夜欧美电影在线观看| 精品国产区一区| 粉嫩13p一区二区三区| 成人免费小视频| 欧美精三区欧美精三区| 久久99精品久久久| 国产精品久久久久久久久搜平片| 欧美综合天天夜夜久久| 免费xxxx性欧美18vr| 久久精品视频在线看| 色婷婷一区二区| 激情五月激情综合网| 亚洲欧洲精品天堂一级| 欧美日韩aaa| 成人小视频在线观看| 亚洲大片在线观看| 国产亚洲欧美日韩俺去了| 色欧美片视频在线观看| 精品无码三级在线观看视频| 亚洲欧美日韩久久精品| 欧美一级理论性理论a| 懂色av一区二区三区免费观看| 亚洲第一av色| 亚洲天堂免费看| 日韩精品一区二| 在线观看成人小视频| 国产美女在线观看一区| 午夜精品久久久久久久99樱桃 | 国产网站一区二区三区| 在线视频欧美精品| 国产一区二区美女| 香蕉成人啪国产精品视频综合网| 国产精品免费av| 欧美v国产在线一区二区三区| 色欧美乱欧美15图片| 国产在线精品一区二区| 午夜精品一区在线观看| 中文字幕亚洲精品在线观看 | 国内外成人在线视频| 洋洋成人永久网站入口| 国产女人18毛片水真多成人如厕 | 日韩一区二区三区在线| 波多野结衣中文字幕一区二区三区 | 一本色道久久综合狠狠躁的推荐| 狠狠网亚洲精品| 日产国产欧美视频一区精品| 一区二区视频在线| 国产精品久久毛片a| 国产喂奶挤奶一区二区三区| 精品久久人人做人人爰| 制服丝袜亚洲播放| 欧美日韩日日夜夜| 在线免费观看成人短视频| av一区二区久久| 成人免费毛片嘿嘿连载视频| 国产精品一区专区| 韩国精品免费视频| 久久99热狠狠色一区二区| 七七婷婷婷婷精品国产| 日韩中文字幕1| 奇米影视一区二区三区| 五月天欧美精品| 亚洲成人综合网站| 亚洲高清免费视频| 亚洲国产va精品久久久不卡综合| 亚洲图片自拍偷拍| 性做久久久久久免费观看| 午夜影院久久久| 日本在线不卡一区| 美日韩一级片在线观看| 激情欧美日韩一区二区| 精品一区二区三区日韩| 韩国三级中文字幕hd久久精品| 另类调教123区| 国产成人综合亚洲网站| 成人一区在线看| 色av一区二区| 欧美一区二区三区视频免费| 日韩欧美一区二区视频| 精品处破学生在线二十三| 久久久国产午夜精品| 中文字幕第一区二区| 中文字幕中文在线不卡住| 亚洲日本在线天堂| 亚洲成在线观看| 激情深爱一区二区| 99久久99久久精品免费看蜜桃 | 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 欧美调教femdomvk| 日韩欧美一二三| 中文字幕一区二区三| 性久久久久久久久| 精品亚洲国内自在自线福利| 丁香婷婷综合色啪| 欧美色区777第一页| 精品成人私密视频| 一区二区三区小说| 久久精品av麻豆的观看方式| 丰满少妇久久久久久久| 色av成人天堂桃色av| 日韩精品一区二区三区老鸭窝 | 国产精品自在欧美一区| 色综合天天做天天爱| 在线成人高清不卡| 欧美激情中文字幕| 亚洲va韩国va欧美va精品| 国产精品996| 欧美日本韩国一区二区三区视频| 精品国产精品网麻豆系列| 《视频一区视频二区| 蜜桃av一区二区在线观看| 成人高清在线视频| 日韩一区二区三| 亚洲精品第1页| 国产成人综合在线| 91精品一区二区三区在线观看| 亚洲欧洲精品一区二区三区| 久久91精品国产91久久小草| 日韩精品一区二区三区在线观看| 国产精品美女www爽爽爽| 蜜臀久久99精品久久久久宅男| 99视频一区二区| 久久久久久久久蜜桃| 日本成人在线电影网| 91在线精品一区二区三区| 精品sm在线观看| 丝袜美腿成人在线| 在线亚洲+欧美+日本专区| 国产日韩欧美一区二区三区综合| 日韩avvvv在线播放| 色婷婷综合激情| 亚洲欧洲av在线| 国产成人免费网站| 欧美mv日韩mv亚洲| 首页国产欧美久久| 欧洲激情一区二区| 亚洲欧洲色图综合| 国产成人av电影在线播放| 日韩欧美一区在线观看| 天堂va蜜桃一区二区三区| 在线一区二区三区四区| 中文字幕一区二区三区精华液| 国产激情一区二区三区四区| 日韩欧美色电影| 美女网站一区二区| 91精品国产欧美一区二区成人 | 亚洲黄色免费网站| av资源站一区| 亚洲欧洲成人自拍| 99精品视频在线观看| 中文字幕亚洲在| 色视频欧美一区二区三区| 国产精品成人免费| 91亚洲精华国产精华精华液| 国产精品国产三级国产专播品爱网| 国产91对白在线观看九色| 久久久www成人免费无遮挡大片 | 成人在线综合网站| 国产精品嫩草99a| 色综合视频在线观看| 亚洲欧洲国产专区| 色天天综合色天天久久| 一区二区三区美女| 欧美日韩一区视频| 水蜜桃久久夜色精品一区的特点| 欧美精品久久久久久久多人混战 | 亚洲欧美日韩一区二区三区在线观看| 91在线观看免费视频| 一区二区三区精品视频| 精品视频一区二区不卡| 日本欧美一区二区| 久久久精品国产免大香伊| 不卡视频一二三| 午夜精品免费在线观看| 欧美成人vr18sexvr| 国产激情91久久精品导航| 国产精品久久久久三级| 91色综合久久久久婷婷| 亚洲国产毛片aaaaa无费看| 91精品婷婷国产综合久久 | 国产成人av网站| 亚洲一区在线免费观看| 51精品视频一区二区三区| 国产一区二区电影|