当前位置: 首页>>代码示例>>C++>>正文


C++ StringPtr::isValid方法代码示例

本文整理汇总了C++中StringPtr::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ StringPtr::isValid方法的具体用法?C++ StringPtr::isValid怎么用?C++ StringPtr::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringPtr的用法示例。


在下文中一共展示了StringPtr::isValid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnTextChange

LRESULT C_SpinButton::OnTextChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	C_STLException::install();

	try {

		TCHAR t[32];
		m_ed.SendMessage(WM_GETTEXT, 1023, reinterpret_cast<LPARAM>(t));

		String s(t);

		StringPtr ptr = s.Find(_T('-'));

		if (ptr.isValid()) {

			if (ptr.Index() > 0) {

				s = s.Left(ptr.Index());
				m_ed.SendMessage(WM_SETTEXT, s.GetLength(), reinterpret_cast<LPARAM>(s.toLPCTSTR()));
				m_ed.SendMessage(EM_SETSEL, s.GetLength(), s.GetLength());

				return S_OK;
			}
		}

		float f = static_cast<float>(s.toDouble());
		
		if (m_fValue != f) {

			if (m_fMinValue == m_fMaxValue || (f >= m_fMinValue && f <= m_fMaxValue)) {

				InternalSetValue(f);
				FireChangeMessage();
			}
			else {
				
				MessageBeep(0xFFFFFFFF);
				DisplayValue();

				return S_OK;
			}
		}

		if (0 == s.GetLength()) {
			DisplayValue();
		}
	}
	catch (C_STLNonStackException const &exception) {
		exception.Log(_T("Exception in C_SpinButton::"));
	}

	return S_OK;
}
开发者ID:ElliottBignell,项目名称:HeadCase,代码行数:53,代码来源:SpinButton.cpp

示例2: Retrieve

STDMETHODIMP C_FloodedFill::Retrieve(I_Archive *arc) 
{ 
	C_STLException::install();

	try {

		BSTR bs = NULL;
		
		if (S_OK != arc->RetrieveString(&bs)) {
			return E_FAIL;
		}

		String s(bs);
		String::FreeBSTR(&bs);

		static String enditem(_T("/mmp:item"));
		static String fill(_T("mmp:floodfill"));
		static String endfill(_T("/mmp:floodfill"));

		while (!s.toLower().Find(endfill).isValid()) {

			StringPtr ptrItem = s.Find(enditem);

			if (ptrItem.isValid()) {

				arc->Rollback();
				break; 
			}

			StringPtr ptrStart = s.Find(fill);

			if (ptrStart.isValid()) {

				StringPtr ptrStyle = s.Find(_T("colours"));
				StringPtr ptrLeft = s.Find(_T("\""), ptrStyle);

				if (ptrLeft.isValid()) {

					ptrLeft++;
					StringPtr ptrRight = s.Find(_T("\""), ptrLeft);

					if (ptrRight.isValid()) {

						String style = s.Mid(ptrLeft.Index(), ptrRight.Index() - ptrLeft.Index());

						if (style.GetLength() > 0) {

							T_PointerArray<String> sa;

							style.Split(_T(':'), &sa);

							m_nCount = sa.GetLength();
							
							m_saColours.ReDim(m_nCount);

							for (int n = 0; n < m_nCount; n++) {
								*m_saColours[n] = sa[n]->toInteger();
							}
						}
					}
				}
			}
			else {

				arc->Rollback();
				EatTag(arc);
			}

			if (S_OK != arc->RetrieveString(&bs)) {
				return E_FAIL;
			}

			s = bs;
			String::FreeBSTR(&bs);
		}
	}
	catch (C_STLNonStackException const &exception) {
		exception.Log(_T("Exception in C_floodFill::Retrieve"));
	}

	return S_OK;
}
开发者ID:ElliottBignell,项目名称:HeadCase,代码行数:82,代码来源:FloodFill.cpp

示例3: Retrieve

STDMETHODIMP C_Items::Retrieve(I_Archive * arc)
{
	if (!arc)
		return E_POINTER;

	C_STLException::install();

	//TODO - templatize this function and stick it in a base class.
	try {

		BSTR bs = NULL;
		unsigned int len = 0;

		if (S_OK != arc->RetrieveString(&bs)) {
			return E_FAIL;
		}

		String s(bs);
		s.toLower();
		String::FreeBSTR(&bs);

		static String tags[5] = {
			_T("mmp:item"),
			_T("mmp:text"),
			_T("mmp:node"),
			_T("mmp:picture"),
			_T("mmp:branch")
		};

		typedef enum ematches {
			plainitem,
			text,
			node,
			picture,
			branch
		};

		static String types[4] = {
			_T("node"),
			_T("text-block"),
			_T("picture"),
			_T("branch")
		};

		ematches match = plainitem;

		CLSID clsid;
		IID iid;

		StringPtr ptr(s.Find(tags[plainitem]));
		StringPtr ptrKill(s.Find(tags[plainitem]));

		for (unsigned int test = plainitem; test <= branch; test++) {

			ptr = s.Find(tags[test]);

			if (ptr.isValid()) {

				ptrKill = s.Find(String(_T("/")) + tags[test]);
				match = static_cast<ematches>(test);

				break;
			}
		}

		switch (match) {
		case node:
			clsid = CLSID_Node;
			iid = IID_I_Node;
			break;
		case text:
			clsid = CLSID_TextBlock;
			iid = IID_I_TextBlock;
			break;
		case picture:
			clsid = CLSID_Picture;
			iid = IID_I_Picture;
			break;
		case branch:
			clsid = CLSID_Branch;
			iid = IID_I_Branch;
			break;
		}

		while (ptr.isValid() && !ptrKill.isValid()) {//Check this is the start of an item...

			C_ItemPtr item;

			/////////////////////////////////////////////////////
			//	In a paste operation, the object's GUID must be ignored
			//	- a new object is being created with its own identity.
			BOOL b = FALSE;
			BOOL bPreserveID = TRUE;
			BSTR bs = NULL;

			arc->get_PreserveIdentities(&bPreserveID);

			if (bPreserveID) {

				/////////////////////////////////////////////////////
//.........这里部分代码省略.........
开发者ID:ElliottBignell,项目名称:HeadCase,代码行数:101,代码来源:Items.cpp


注:本文中的StringPtr::isValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。