本文整理汇总了C++中StringPtr::Index方法的典型用法代码示例。如果您正苦于以下问题:C++ StringPtr::Index方法的具体用法?C++ StringPtr::Index怎么用?C++ StringPtr::Index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringPtr
的用法示例。
在下文中一共展示了StringPtr::Index方法的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;
}
示例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;
}
示例3: Retrieve
//.........这里部分代码省略.........
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) {
/////////////////////////////////////////////////////
// Get the GUID to identify the object. Check if it
// exists already - if so, divert the serialisation data
// to the existing object and add a reference to the
// Children collection.
String sUUID;
StringPtr ptrUUID = s.Find(_T("uuid"));
if (ptrUUID.isValid()) {
StringPtr ptrLeft = s.Find(_T("\""), ptrUUID);
ptrLeft++;
if (ptrLeft.isValid()) {
StringPtr ptrRight = s.Find(_T("\""), ptrLeft);
if (ptrRight.isValid()) {
sUUID = s.Mid(ptrLeft.Index(), ptrRight.Index() - ptrLeft.Index());
}
else {
sUUID = s.Right(s.GetLength() - ptrLeft.Index());
}
T_SafeArray<char> buffer(sUUID.GetLength() + 1);
::_stprintf(buffer[0], _T("%s\0"), sUUID.toLPCTSTR());
GUID guid = String(buffer[0]).toGUID();
map<GUID, I_MapItem*>::iterator it = m_S_Items.find(guid);
if (it != m_S_Items.end()) {
//The object with this GUID already exists in the item map
item = (*it).second;
_ASSERTE(item);
if (item) {
VARIANT v;
C_UniquePtr unique(item);
if (unique) {
unique->get_UID(&bs);
}
VariantInit(&v);
v.vt = VT_BSTR;