本文整理汇总了C++中StrAnsi::Chars方法的典型用法代码示例。如果您正苦于以下问题:C++ StrAnsi::Chars方法的具体用法?C++ StrAnsi::Chars怎么用?C++ StrAnsi::Chars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StrAnsi
的用法示例。
在下文中一共展示了StrAnsi::Chars方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BreakUndoTask
/*----------------------------------------------------------------------------------------------
${IActionHandler#BreakUndoTask}
----------------------------------------------------------------------------------------------*/
STDMETHODIMP ActionHandler::BreakUndoTask(BSTR bstrUndo, BSTR bstrRedo)
{
BEGIN_COM_METHOD;
ChkComBstrArg(bstrUndo);
ChkComBstrArg(bstrRedo);
if (m_fUndoOrRedoInProgress)
return S_OK;
int nSaveDepth = m_nDepth;
EndOuterUndoTask();
BeginUndoTask(bstrUndo, bstrRedo);
m_nDepth = nSaveDepth;
#ifdef DEBUG_ACTION_HANDLER
StrAnsi sta;
sta.Format("BreakUndoTask:");
sta.FormatAppend(" m_iCurrSeq=%d, m_viSeqStart=%d, m_iuactCurr=%d, m_vquact=%d, m_viMarks=%d, m_nDepth=%d\n",
m_iCurrSeq, m_viSeqStart.Size(), m_iuactCurr, m_vquact.Size(), m_viMarks.Size(), m_nDepth);
::OutputDebugStringA(sta.Chars());
#endif//DEBUG_ACTION_HANDLER
END_COM_METHOD(g_factActh, IID_IActionHandler);
}
示例2: EndUndoTask
/*----------------------------------------------------------------------------------------------
${IActionHandler#EndUndoTask}
----------------------------------------------------------------------------------------------*/
STDMETHODIMP ActionHandler::EndUndoTask()
{
BEGIN_COM_METHOD;
if (m_fUndoOrRedoInProgress)
return S_OK;
if (m_nDepth <= 0)
{
return E_UNEXPECTED;
}
else
{
--m_nDepth;
if (m_nDepth == 0)
{
// cleans no-op undo tasks
EndOuterUndoTask();
}
}
#ifdef DEBUG_ACTION_HANDLER
StrAnsi sta;
sta.Format("EndUndoTask:");
sta.FormatAppend(" m_iCurrSeq=%d, m_viSeqStart=%d, m_iuactCurr=%d, m_vquact=%d, m_viMarks=%d, m_nDepth=%d\n",
m_iCurrSeq, m_viSeqStart.Size(), m_iuactCurr, m_vquact.Size(), m_viMarks.Size(), m_nDepth);
::OutputDebugStringA(sta.Chars());
#endif//DEBUG_ACTION_HANDLER
END_COM_METHOD(g_factActh, IID_IActionHandler);
}
示例3: AddTstFunc
void MacroBase::AddTstFunc(StrAnsi name, int ID)
{
// If no valid file object
if (!m_outfile.is_open()) return;
// name is just for visual reference, ID actually identifies the function
m_outfile << name.Chars() << " " << ID << " ";
}
示例4: AddAction
/*----------------------------------------------------------------------------------------------
${IActionHandler#AddAction}
----------------------------------------------------------------------------------------------*/
STDMETHODIMP ActionHandler::AddAction(IUndoAction * puact)
{
BEGIN_COM_METHOD;
ChkComArgPtr(puact);
if (m_fUndoOrRedoInProgress)
return S_OK;
if(m_fCreateMarkIfNeeded && m_viMarks.Size() == 0)
{
// m_fCreateMarkIfNeeded probably didn't get reset (TE-4856)
Assert(m_nDepth <= 0 || m_fStartedNext);
int hmark;
CheckHr(Mark(&hmark));
Assert(hmark == 1); // Should only have 1 mark!
}
ContinueUndoTask();
AddActionAux(puact);
EndUndoTask();
#ifdef DEBUG_ACTION_HANDLER
StrAnsi sta;
sta.Format("AddAction:");
sta.FormatAppend(" m_iCurrSeq=%d, m_viSeqStart=%d, m_iuactCurr=%d, m_vquact=%d, m_viMarks=%d, m_nDepth=%d\n",
m_iCurrSeq, m_viSeqStart.Size(), m_iuactCurr, m_vquact.Size(), m_viMarks.Size(), m_nDepth);
::OutputDebugStringA(sta.Chars());
#endif//DEBUG_ACTION_HANDLER
END_COM_METHOD(g_factActh, IID_IActionHandler);
}
示例5: TransFuncDump
/*----------------------------------------------------------------------------------------------
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
}
示例6: WriteAnsi
void MacroBase::WriteAnsi(StrAnsi param)
{
if (!m_outfile.is_open()) return;
// All strings are terminated by the ALT-255 character. It is doubtful the user will type this
// character and so terminate the actual log prematurely. Using this obscure character
// safeguards against that
m_outfile << param.Chars() << "_" << " ";
}
示例7: 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() << "_" << " ";
}
示例8: WriteToStream
void WriteToStream(std::ostream & strmOut, bool fNoPath)
{
int ich = m_staFile.Length();
// Strip off the file path.
while (fNoPath && ich > 0 && m_staFile[ich - 1] != '\\')
ich--;
StrAnsi staStripped = m_staFile.Right(m_staFile.Length() - ich);
strmOut << staStripped.Chars() << "(" << m_nLineOrig << ")";
}
示例9: ReadUni
StrUni MacroBase::ReadUni()
{
if (!m_infile.is_open()) return NULL;
// Both Unicode and Ansi are written as Ansi to file. Convert to Unicode after retrieiving
// ansi interpretation
StrAnsi ans = ReadAnsi();
StrUni stuUni = ans.Chars();
return stuUni;
}
示例10: SetKeyboard_Windows
/*----------------------------------------------------------------------------------------------
Set the keyboard the Windows API way
----------------------------------------------------------------------------------------------*/
void SetKeyboard_Windows(int lcid)
{
#ifdef Tracing_KeybdSelection
StrAnsi sta;
sta.Format("LgTextServices::SetKeyboard(%d) [not Keyman]%n", lcid);
::OutputDebugStringA(sta.Chars());
#endif
int nLangId = LANGIDFROMLCID(lcid);
HKL hkl = (HKL)nLangId;
if (hkl == 0)
hkl = (HKL)::GetSystemDefaultLangID();
// If we're not activating a Keyman keyboard, activate the appropriate OS IM.
// Microsoft says we should only do this if we were not able to do it using
// ActivateLanguageProfile (private communication to JohnT).
#ifdef Tracing_KeybdSelection
sta.Format("LgTextServices::SetKeyboard(%d) - "
"hkl = %x, ::GetKeyboardLayout() = %x%n",
lcid, hkl, ::GetKeyboardLayout(0));
::OutputDebugStringA(sta.Chars());
#endif
if (hkl != ::GetKeyboardLayout(0))
{
// We need to work out whether we're using at least W2000, because
// KLF_SETFORPROCESS is not supported before that.
UINT flags = 0;
if (IsWin2kOrHigher())
{
//Windows 2000 or better, we can use KLF_SETFORPROCESS.
flags = KLF_SETFORPROCESS;
}
#ifdef Tracing_KeybdSelection
StrAnsi sta;
sta.Format("LgTextServices::SetKeyboard(%d) - "
"::ActivateKeyboardLayout(%x, %x) [nLangId = %d]\n",
lcid, hkl, flags, nLangId);
::OutputDebugStringA(sta.Chars());
#endif
::ActivateKeyboardLayout(hkl, flags);
Assert(sizeof(int) >= sizeof(hkl));
}
}
示例11: SetMacroOut
bool MacroBase::SetMacroOut(StrAnsi staMcr)
{
// Same functionality as SetMacroIn, except used for writing to files
if (!strcmp(staMcr.Chars(),""))
return false;
m_stafileout = staMcr;
if (m_outfile.is_open())
m_outfile.close();
m_outfile.open(m_stafileout.Chars(), ios_base::out);
return m_outfile.is_open();
}
示例12: SaveToFile
/*----------------------------------------------------------------------------------------------
Save the text to a file.
----------------------------------------------------------------------------------------------*/
bool WpDa::SaveToFile(StrAnsi staFileName)
{
IStreamPtr qstrm;
FileStream::Create(staFileName.Chars(), kfstgmWrite | kfstgmCreate, &qstrm);
// FileStream::Create("c:\\output.txt", kfstgmWrite | kfstgmCreate, &qstrm);
ULONG cbWritten;
// Write byte-order mark.
byte b = 0xFF;
CheckHr(qstrm->Write(&b, 1, &cbWritten));
b = 0xFE;
CheckHr(qstrm->Write(&b, 1, &cbWritten));
int ctss;
CheckHr(get_VecSize(1, kflidStText_Paragraphs, &ctss));
for (int itss = 0; itss < ctss; itss++)
{
ITsStringPtr qtss;
CheckHr(get_StringProp(itss + 2, kflidStTxtPara_Contents, &qtss));
BSTR bstr = NULL;
int cchw;
CheckHr(qtss->get_Length(&cchw));
qtss->GetChars(0, cchw, &bstr);
// Write the string to the file.
if (cchw > 0)
{
Assert(bstr);
CheckHr(qstrm->Write(bstr, cchw * isizeof(wchar), &cbWritten));
}
if (itss < ctss - 1)
{
// CRLF--little-endian
b = 13;
CheckHr(qstrm->Write(&b, 1, &cbWritten));
b = 0;
CheckHr(qstrm->Write(&b, 1, &cbWritten));
b = 10;
CheckHr(qstrm->Write(&b, 1, &cbWritten));
b = 0;
CheckHr(qstrm->Write(&b, 1, &cbWritten));
}
ReleaseBstr(bstr);
}
return true;
}
示例13: SetMacroIn
bool MacroBase::SetMacroIn(StrAnsi staMcr)
{
// Open file "staMcr" for reading unless no name given
if (!strcmp(staMcr.Chars(), ""))
return false;
// Assign file to open to class member
m_stafilein = staMcr;
// If the file is already open, close it before opening it again
if (m_infile.is_open())
m_infile.close();
// Now open the file
m_infile.open(m_stafilein.Chars(), ios_base::in);
return m_infile.is_open();
}
示例14: Commit
/*----------------------------------------------------------------------------------------------
${IActionHandler#Commit}
----------------------------------------------------------------------------------------------*/
STDMETHODIMP ActionHandler::Commit()
{
BEGIN_COM_METHOD;
HRESULT hr = E_FAIL;
HRESULT hrFinal = S_OK;
if (m_vquact.Size())
{
// JohnT 10/22/01: this can happen, typically if the only thing in the sequence is a
// position mark. We could try to check for that but it doesn't seem worth it. Nothing
// actually depends on having at least one sequence start here.
//Assert(m_viSeqStart.Size() > 0);
// Commit all actions.
for (int i = 0; i <= m_iuactCurr; i++)
{
// If for some reason, we cannot commit an action that is part of a sequence, it's
// just too bad. We can't undo a commited action so we might as well just amble on
// and hope for the best.
IgnoreHr(hr = m_vquact[i]->Commit());
if (FAILED(hr))
{
hrFinal = hr;
}
}
EmptyStack();
}
#ifdef DEBUG_ACTION_HANDLER
StrAnsi sta;
sta.Format("Commit:");
sta.FormatAppend(" m_iCurrSeq=%d, m_viSeqStart=%d, m_iuactCurr=%d, m_vquact=%d, m_viMarks=%d, m_nDepth=%d\n",
m_iCurrSeq, m_viSeqStart.Size(), m_iuactCurr, m_vquact.Size(), m_viMarks.Size(), m_nDepth);
::OutputDebugStringA(sta.Chars());
#endif//DEBUG_ACTION_HANDLER
return hrFinal;
END_COM_METHOD(g_factActh, IID_IActionHandler);
}
示例15: OnExtendedKey
void ViewTest2::WrapOnExtendedKey(int _chw, VwShiftStatus _ss)
{
StrAnsi staExt;
switch (_ss)
{
case kfssNone:
staExt.Append("None");
break;
case kgrfssShiftControl:
staExt.Append("Shift + Control");
break;
case kfssShift:
staExt.Append("Shift ");
break;
case kfssControl:
staExt.Append("Control ");
break;
default:
staExt.Append("Undefined state");
}
m_psts->OutputFormat(" FUNCTION: OnExtendedKey(%d, %s)\n", _chw, staExt.Chars());
CheckHr(m_qrootb->OnExtendedKey(_chw, _ss));
}