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


C++ StrUni类代码示例

本文整理汇总了C++中StrUni的典型用法代码示例。如果您正苦于以下问题:C++ StrUni类的具体用法?C++ StrUni怎么用?C++ StrUni使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetModuleVersion

/*----------------------------------------------------------------------------------------------
	Get the version information for a module. It is passed the path name to the module.
----------------------------------------------------------------------------------------------*/
StrUni GetModuleVersion(const OLECHAR * pchPathName)
{
	StrUni stuRet;
#ifdef WIN32
	StrApp staPathName = pchPathName;
	achar * pchaPathName = const_cast<achar *>(staPathName.Chars());

	DWORD dwDum; // Always set to zero.
	DWORD cb = GetFileVersionInfoSize(pchaPathName, &dwDum);

	LPVOID pBlock = (LPVOID) _alloca(cb);

	if (!GetFileVersionInfo(pchaPathName, 0, cb, pBlock))
		return stuRet; // Can't get requested info

	VS_FIXEDFILEINFO * pffi;
	uint nT;
	::VerQueryValue(pBlock, _T("\\"), (void **)&pffi, &nT);

	stuRet.Format(L"Version: %d, %d, %d, %d", HIWORD(pffi->dwFileVersionMS),
		LOWORD(pffi->dwFileVersionMS), HIWORD(pffi->dwFileVersionLS),
		LOWORD(pffi->dwFileVersionLS));
#endif
	return stuRet;
}
开发者ID:FieldDB,项目名称:FieldWorks,代码行数:28,代码来源:StackDumper.cpp

示例2: TestCompare

void TestCollatingEngine::TestCompare(StrUni stuVal1, StrUni stuVal2, int nExpected)
{
	HRESULT hr;
	int nActual1, nActual2;
	SmartBstr sbstrKey1, sbstrKey2;
	SmartBstr sbstrVal1 = (stuVal1 ? stuVal1.Bstr() : NULL);
	SmartBstr sbstrVal2 = (stuVal2 ? stuVal2.Bstr() : NULL);

	// First comparison method
	hr = m_qcoleng->Compare(sbstrVal1, sbstrVal2, fcoDefault, &nActual1);
	TestHrFail(hr, "String compare");

	// Make sure we get the same result with the other method:
	// by getting the keys themselves and comparing them.
	hr = m_qcoleng->get_SortKey(sbstrVal1, fcoDefault, &sbstrKey1);
	TestFailZero(sbstrKey1, "get_SortKey");
	TestHrFail(hr, "getting SortKey on string 1");
	hr = m_qcoleng->get_SortKey(sbstrVal2, fcoDefault, &sbstrKey2);
	TestFailZero(sbstrKey2, "get_SortKey");
	TestHrFail(hr, "getting SortKey on string 2");

	nActual2 = wcscmp(sbstrKey1, sbstrKey2);

	if (sgn(nActual1) != sgn(nActual2))
		Failure("String comparison yielded inconsistent results");

	if (sgn(nActual1) != sgn(nExpected))
	{
		FailureFormat(L"Comparison of %s to %s gave %d instead of %d.",
			(sbstrVal1 ? sbstrVal1 : L"NULL"), (sbstrVal2 ? sbstrVal2 : L"NULL"),
			nActual1, nExpected);
	}

	return;
}
开发者ID:agran147,项目名称:FieldWorks,代码行数:35,代码来源:TstLanguage.cpp

示例3: ConvertException

StrUni ConvertException(DWORD dwExcept)
{
	StrUni stuResult;
	OLECHAR * pszSimple = ConvertSimpleException(dwExcept);

	if (NULL != pszSimple)
	{
		stuResult = pszSimple;
	}
	else
	{
		LPTSTR lpstrMsgBuf;
		::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
			NULL,
			dwExcept,
			0, // smart search for useful languages
			reinterpret_cast<achar *>(&lpstrMsgBuf),
			0,
			NULL);
		stuResult = lpstrMsgBuf;
		int cch = stuResult.Length();
		if (cch > 1 && stuResult[cch - 2] == '\r')
			stuResult.Replace(cch - 2, cch, (OLECHAR *)NULL);

		// Free the buffer.
		::LocalFree( lpstrMsgBuf );
	}
	return stuResult;
}
开发者ID:agran147,项目名称:FieldWorks,代码行数:29,代码来源:StackDumperWin32.cpp

示例4: InitNewEmpty

/*----------------------------------------------------------------------------------------------
	Initialize the data from the given file, or create a new empty string.
----------------------------------------------------------------------------------------------*/
void WpDa::InitNew(StrAnsi staFileName)
{
	if (staFileName == "")
	{
		InitNewEmpty();
		return;
	}

	Vector<StrUni> vstu;
	ReadTextFromFile(staFileName, vstu);

	HVO * prghvoPara = NewObj HVO[vstu.Size()];
	for (int istu = 0; istu < vstu.Size(); istu++)
		prghvoPara[istu] = istu + 2;
	CacheVecProp(1, kflidStText_Paragraphs, prghvoPara, vstu.Size());
	ITsStrFactoryPtr qtsf;
	qtsf.CreateInstance(CLSID_TsStrFactory);
	int enc = 100; // replace by the right number when we figure out what it is

	for (istu = 0; istu < vstu.Size(); istu++)
	{
		StrUni stuPara = vstu[istu];
		ITsStringPtr qtss;
		CheckHr(qtsf->MakeStringRgch(stuPara.Chars(), stuPara.Length(), enc, &qtss));
		CacheStringProp(istu + 2, kflidStTxtPara_Contents, qtss);
	}

	ITsPropsBldrPtr qtpb;
	qtpb.CreateInstance(CLSID_TsPropsBldr);
	StrUni stuNormal = L"Normal";
	CheckHr(qtpb->SetStrPropValue(kspNamedStyle,stuNormal.Bstr()));

	delete[] prghvoPara;
}
开发者ID:agran147,项目名称:FieldWorks,代码行数:37,代码来源:WpDa.cpp

示例5: TestHrFail

void ViewTest1::TestFontName()
{
	// Trying to retrieve via get_ without a previous put_
	// Something to consider is if there can be a default font name in which case this
	// test would not apply
	SmartBstr sbstrName1;
	HRESULT hr = m_qxvoTest->get_FontName(&sbstrName1);
	TestHrFail(hr, "Function get_FontName failed when passed(by reference) a SmartBstr");
	if (sbstrName1 != NULL)
		Failure("get_FontName without initialization via put_ should have returned error");

	// Sending NULL pointers to functions
	// REVIEW LukeU This test is assuming that a font name of zero length is invalid
	hr = m_qxvoTest->put_FontName(NULL);
	if (!FAILED(hr))
		Failure("Call to function: put_FontName(NULL) should have returned error unless "
			"0 character font name is allowed");

	hr = m_qxvoTest->get_FontName(NULL);
	if (!FAILED(hr))
		Failure("Call to function: get_FontName(NULL) should have returned error on NULL "
			"pointer");

	// "put_ing" and "get_ing" and subsequent value comparison
	StrUni stuFontName = L"Garliz";
	hr = m_qxvoTest->put_FontName(stuFontName.Bstr());
	TestHrFail(hr, "Function put_FontName failed when passed(by value) a bstr");

	CheckHr(m_qxvoTest->get_FontName(&sbstrName1));
	if (wcscmp(stuFontName.Chars(), sbstrName1.Chars()))
		Failure("FontName returned wrong result");
}
开发者ID:agran147,项目名称:FieldWorks,代码行数:32,代码来源:ViewTest.cpp

示例6: Assert

/*----------------------------------------------------------------------------------------------
	Load the data from the given file into an empty window.
----------------------------------------------------------------------------------------------*/
void WpDa::LoadIntoEmpty(StrAnsi staFileName, WpChildWnd * pwcw)
{
	Assert(staFileName != "");
	int ctss;
	CheckHr(get_VecSize(1, kflidStText_Paragraphs, &ctss));
	Assert(ctss <= 1);

	Vector<StrUni> vstu;
	ReadTextFromFile(staFileName, vstu);

	HVO * prghvoPara = NewObj HVO[vstu.Size()];
	for (int istu = 0; istu < vstu.Size(); istu++)
		prghvoPara[istu] = istu + 2;
	CacheVecProp(1, kflidStText_Paragraphs, prghvoPara, vstu.Size());
	ITsStrFactoryPtr qtsf;
	qtsf.CreateInstance(CLSID_TsStrFactory);
	int enc = 100; // replace by the right number when we figure out what it is

	for (istu = 0; istu < vstu.Size(); istu++)
	{
		StrUni stuPara = vstu[istu];
		ITsStringPtr qtss;
		CheckHr(qtsf->MakeStringRgch(stuPara.Chars(), stuPara.Length(), enc, &qtss));
		CacheStringProp(istu + 2, kflidStTxtPara_Contents, qtss);
	}

	ITsPropsBldrPtr qtpb;
	qtpb.CreateInstance(CLSID_TsPropsBldr);
	StrUni stuNormal = L"Normal";
	CheckHr(qtpb->SetStrPropValue(kspNamedStyle, stuNormal.Bstr()));

	delete[] prghvoPara;

	pwcw->ChangeNumberOfStrings(vstu.Size());
}
开发者ID:agran147,项目名称:FieldWorks,代码行数:38,代码来源:WpDa.cpp

示例7: GetModuleHelpFilePath

/*----------------------------------------------------------------------------------------------
	Get a path name for the help file for this module.
	By convention this is the path of the DLL changed to .chm.
----------------------------------------------------------------------------------------------*/
StrUni GetModuleHelpFilePath()
{
	StrUni stuHelpPath = ModuleEntry::GetModulePathName();
	int cch = stuHelpPath.Length();
	int ichStartRep = cch; // Add to end if no dot.
	if (cch >= 3 && stuHelpPath[cch - 4] == '.')
		ichStartRep = cch - 3;
	stuHelpPath.Replace(ichStartRep, cch, L"chm");
	return stuHelpPath;
}
开发者ID:FieldDB,项目名称:FieldWorks,代码行数:14,代码来源:StackDumper.cpp

示例8: IgnoreHr

/*----------------------------------------------------------------------------------------------
	Convert the Graphite character offset to the decomposed NFD
	character offset used internally by views code.
----------------------------------------------------------------------------------------------*/
int FwGrTxtSrc::GrToVwOffset(int grOffset)
{
	if (!m_useNFC)
	{
		// the Graphite offset is a NFD offset
		return grOffset;
	}
	else
	{
		// convert NFC offsets to internal NFD offsets
		if (grOffset == 0)
			return 0;

		HRESULT hr;
		int cch;
		IgnoreHr(hr = m_qts->get_Length(&cch));
		if (FAILED(hr))
			throw;

		if (grOffset > cch)
			// grOffset points beyond the available text, i.e. is invalid.
			return cch + 10; // arbitrary number that is bigger than NFD text

		StrUni stuNfd;
		wchar_t* pchNfd;
		stuNfd.SetSize(cch + 1, &pchNfd);
		IgnoreHr(hr = m_qts->Fetch(0, cch, pchNfd));
		if (FAILED(hr))
			throw;
		pchNfd[cch] = '\0';

		wchar_t szOut[kNFDBufferSize];
		UCharIterator iter;
		uiter_setString(&iter, pchNfd, -1);
		int curGrOffset = 0;
		while (iter.hasNext(&iter))
		{
			int index = iter.getIndex(&iter, UITER_CURRENT);
			if (curGrOffset >= grOffset)
				return index;
			UBool neededToNormalize;
			UErrorCode uerr = U_ZERO_ERROR;
			int outLen = unorm_next(&iter, szOut, kNFDBufferSize, UNORM_NFC, 0, TRUE, &neededToNormalize, &uerr);
			Assert(U_SUCCESS(uerr));
			curGrOffset++;
			for (int i = 1; i < outLen; i++)
			{
				if (curGrOffset >= grOffset)
					return index + i;
				curGrOffset++;
			}
		}
		return iter.getIndex(&iter, UITER_CURRENT);
	}
}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:59,代码来源:FwGr.cpp

示例9: ChkComOutPtr

STDMETHODIMP VwAccessRoot::get_accValue(VARIANT varID, BSTR * pszValue)
{
	BEGIN_COM_METHOD;
	ChkComOutPtr(pszValue);
	if (!m_pbox)
		return CO_E_OBJECTNOTCONNECTED;

	StrUni stuDesc = m_pbox->Description();
	stuDesc.GetBstr(pszValue);

	END_COM_METHOD(g_fact, IID_IAccessible);
}
开发者ID:agran147,项目名称:FieldWorks,代码行数:12,代码来源:VwAccessRoot.cpp

示例10: object

/*----------------------------------------------------------------------------------------------
	Initialize an empty document. It has a document object (always ID 1!) and one paragraph
	containing (implicitly) an empty string. Style is set to Normal
	Review SharonC(JohnT): what encoding should the empty string have??
----------------------------------------------------------------------------------------------*/
void WpDa::InitNewEmpty()
{
	HVO hvoPara = 2;
	CacheVecProp(1, kflidStText_Paragraphs, &hvoPara, 1);
	ITsStrFactoryPtr qtsf;
	qtsf.CreateInstance(CLSID_TsStrFactory);
	ITsStringPtr qtss;
	int enc = 100;
	CheckHr(qtsf->MakeStringRgch(L"", 0, enc, &qtss));
	CacheStringProp(hvoPara, kflidStTxtPara_Contents, qtss);
	ITsPropsBldrPtr qtpb;
	qtpb.CreateInstance(CLSID_TsPropsBldr);
	StrUni stuNormal = L"Normal";
	CheckHr(qtpb->SetStrPropValue(kspNamedStyle, stuNormal.Bstr()));
}
开发者ID:agran147,项目名称:FieldWorks,代码行数:20,代码来源:WpDa.cpp

示例11: _set_se_translator

/*----------------------------------------------------------------------------------------------
	This function can be installed to translate windows exceptions into C++ internal error
	exceptions. Only the main program should do this. To install, just call
	_set_se_translator(TransFuncDump);.

	This is of dubious value because if the error occurs inside a COM component, the Throwable
	exception will not be recognized, and exception handling will just catch "..." and generate
	a new stack dump. However, installing it at least achieves better stack dumps for errors
	in code linked into the main program.

	We could install at the start of every COM interface method, and restore upon return.
	However this would be computationally expensive. Consider doing this in a particular method
	if you are trying to track down a problem in that method.

	We could have each module install this function on being loaded, and check whether the
	error occurs in its own code, and if not call the previous error handler. But this
	only works reliably if modules are never unloaded, or only in reverse order of loading,
	which I don't see how to ensure.

	We could also get really fancy, with some sort of central manager which knows which error
	translator to use for each module. This has not seemed worthwhile to me so far.
----------------------------------------------------------------------------------------------*/
void TransFuncDump( unsigned int u, EXCEPTION_POINTERS * pExp)
{
#ifdef WIN32
	HANDLE hThread;
	DWORD dwCode = pExp->ExceptionRecord->ExceptionCode;
	StrUni stuException = ConvertException(dwCode);
	DuplicateHandle( GetCurrentProcess(), GetCurrentThread(),
		GetCurrentProcess(), &hThread, 0, false, DUPLICATE_SAME_ACCESS );
	StrAnsi staMsg;
	staMsg.Format("Stack Dump for exception: %S (%d)", stuException.Chars(), dwCode);
	StackDumper::ShowStack( hThread, *(pExp->ContextRecord), const_cast<char *>(staMsg.Chars()) );
	CloseHandle( hThread );
	StrUni stuMsg(staMsg.Chars());
	throw ThrowableSd(E_UNEXPECTED, stuMsg.Chars(), 0, StackDumper::GetDump());
#endif
}
开发者ID:FieldDB,项目名称:FieldWorks,代码行数:38,代码来源:StackDumper.cpp

示例12: WriteUni

void MacroBase::WriteUni(StrUni param)
{
	if (!m_outfile.is_open())	return;
	// All unicode strings are first transformed into ansi strings and then written to file as
	// an ansi
	StrAnsi staAnsi = param.Chars();
	m_outfile << staAnsi.Chars() << "_" << " ";
}
开发者ID:agran147,项目名称:FieldWorks,代码行数:8,代码来源:MacroBase.cpp

示例13: CheckHr

/*----------------------------------------------------------------------------------------------
	Change all the occurrences of the old styles names to the new names, and delete any
	obsolete names.
----------------------------------------------------------------------------------------------*/
bool FwDbMergeStyles::ProcessFormatting(ComVector<ITsTextProps> & vqttp,
	StrUni stuDelete)
{
	bool fAnyChanged = false;
	for (int ittp = 0; ittp < vqttp.Size(); ittp++)
	{
		SmartBstr sbstr;
		HRESULT hr;
		CheckHr(hr = vqttp[ittp]->GetStrPropValue(ktptNamedStyle, &sbstr));
		if (hr == S_OK && sbstr.Length() > 0)
		{
			ITsPropsBldrPtr qtpb = NULL;
			StrUni stuOld(sbstr.Chars());
			StrUni stuNew;
			if (Delete(stuOld))
			{
				CheckHr(vqttp[ittp]->GetBldr(&qtpb));
				if (stuDelete.Length() == 0)
				{
					// If the style name to delete is empty, we want to pass null
					// so that the named style string property is removed.
					CheckHr(qtpb->SetStrPropValue(ktptNamedStyle, NULL));
				}
				else
					CheckHr(qtpb->SetStrPropValue(ktptNamedStyle, stuDelete.Bstr()));

			}
			else if (Rename(stuOld, stuNew))
			{
				CheckHr(vqttp[ittp]->GetBldr(&qtpb));
				CheckHr(qtpb->SetStrPropValue(ktptNamedStyle, stuNew.Bstr()));
			}

			if (qtpb)
			{
				ITsTextPropsPtr qttpNew;
				CheckHr(qtpb->GetTextProps(&qttpNew));
				vqttp[ittp] = qttpNew;
				fAnyChanged = true;
			}
		}
	}

	return fAnyChanged;
}
开发者ID:agran147,项目名称:FieldWorks,代码行数:49,代码来源:FwDbMergeStyles.cpp

示例14: ChkComArgPtr

/*----------------------------------------------------------------------------------------------
	Insert material as appropriate to display the specified object.
	This method has not yet been tested...maybe not even compiled?
----------------------------------------------------------------------------------------------*/
STDMETHODIMP VwBaseVc::DisplayEmbeddedObject(IVwEnv * pvwenv, HVO hvo)
{
	BEGIN_COM_METHOD;
	ChkComArgPtr(pvwenv);
	// See if it is a CmPicture.
	ISilDataAccessPtr qsda;
	CheckHr(pvwenv->get_DataAccess(&qsda));
	int clsid;
	CheckHr(qsda->get_IntProp(hvo, kflidCmObject_Class, &clsid));
	if (clsid != kclidCmPicture)
		return S_OK; // don't know how to deal with it.
	StrUni stuRootDir = DirectoryFinder::FwRootDataDir();
	HVO hvoFile;
	CheckHr(qsda->get_ObjectProp(hvo, kflidCmPicture_PictureFile, &hvoFile));
	if (hvoFile == 0)
		return S_OK;
	SmartBstr sbstrFileName;
	CheckHr(qsda->get_UnicodeProp(hvoFile, kflidCmFile_InternalPath, &sbstrFileName));
	if (sbstrFileName.Length() == 0)
		return S_OK;
	StrUni stuPath;
	stuPath.Format(L"%s,%s,%s", stuRootDir.Chars(), L"\\", sbstrFileName.Chars());
	IPicturePtr qpic;
	try
	{
		IStreamPtr qstrm;
		FileStream::Create(stuPath, STGM_READ, &qstrm);
		STATSTG stg;
		CheckHr(qstrm->Stat(&stg, STATFLAG_NONAME));
		LONG cbdata = (LONG)stg.cbSize.QuadPart;
		CheckHr(::OleLoadPicture(qstrm, cbdata, FALSE, IID_IPicture, (LPVOID *)&qpic));
		CheckHr(pvwenv->AddPicture(qpic, ktagNotAnAttr, 0, 0));
	}
	catch (...)
	{
		return S_OK; // if anything goes wrong (e.g., file not found), just give up for now.
		// Todo: insert a 'file XXX not found string.
	}
	// Todo: also add the caption.

	END_COM_METHOD(g_fact, IID_IVwViewConstructor);
}
开发者ID:agran147,项目名称:FieldWorks,代码行数:46,代码来源:VwBaseVc.cpp

示例15: RecordError

/*----------------------------------------------------------------------------------------------
	General purpose method to set up and store an error, rather than throw an exception
	in the normal way.
----------------------------------------------------------------------------------------------*/
HRESULT StackDumper::RecordError(REFGUID iid, StrUni stuDescr, StrUni stuSource,
	int hcidHelpId, StrUni stuHelpFile)
{
	// We are going to make a new error info object.
	ICreateErrorInfoPtr qcerrinfo;
	IErrorInfoPtr qerrinfo;
	HRESULT hr;

	// If we can't get a new error object, the only documented cause is E_OUTOFMEMORY.
	if (FAILED(hr = ::CreateErrorInfo(&qcerrinfo)))
	{
		return E_OUTOFMEMORY;
	}
	if (FAILED(hr = qcerrinfo->QueryInterface(IID_IErrorInfo, (LPVOID FAR*) &qerrinfo)))
	{
		return E_UNEXPECTED;
	}

	hr = qcerrinfo->SetDescription(const_cast<OLECHAR *>(stuDescr.Chars()));
	if (FAILED(hr))
		return hr;
	hr = qcerrinfo->SetGUID(iid);
	if (FAILED(hr))
		return hr;
	hr = qcerrinfo->SetSource(const_cast<OLECHAR *>(stuSource.Chars()));
	if (FAILED(hr))
		return hr;
	hr = qcerrinfo->SetHelpFile(const_cast<OLECHAR *>(stuHelpFile.Chars()));
	if (FAILED(hr))
		return hr;
	if (!hcidHelpId)
		hcidHelpId = khcidNoHelpAvailable;
	hr = qcerrinfo->SetHelpContext(hcidHelpId);
	if (FAILED(hr))
		return hr;

	::SetErrorInfo(0, qerrinfo);
	return hr;
}
开发者ID:FieldDB,项目名称:FieldWorks,代码行数:43,代码来源:StackDumper.cpp


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