本文整理汇总了C++中StdString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ StdString::c_str方法的具体用法?C++ StdString::c_str怎么用?C++ StdString::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StdString
的用法示例。
在下文中一共展示了StdString::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateFileItem
void COptionTreeWrapper::CreateFileItem(CHashString compName, ViewFormatObject *obj, COptionTreeItem* root)
{
IFileViewObject *fileObject = dynamic_cast<IFileViewObject*>(obj);
if(fileObject == NULL)
{
StdString error = _T("Could not cast to a CFileViewObject");
::MessageBox(NULL, error, _T("Invalid Operaton"), MB_OK);
return;
}
StdString type = fileObject->GetBasicType();
StdString name = fileObject->GetName();
StdString fileName = fileObject->GetDefFile();
StdString defExt = fileObject->GetDefExt();
StdString extFilter = fileObject->GetExtFilter();
COptionTreeItemFile *otiFile;
otiFile = (COptionTreeItemFile*)m_mTrees[compName.GetUniqueID()].m_Tree->InsertItem( new COptionTreeItemFile(), root );
otiFile->SetLabelText(name.c_str());
otiFile->SetInfoText(_T(""));
otiFile->CreateFileItem((const TCHAR*)fileName,
defExt.c_str(),
extFilter.c_str(),
OT_FILE_OPENDIALOG | OT_FILE_SHOWFULLPATH,
OFN_OVERWRITEPROMPT);
}
示例2: Serialize
void CDetailObject::Serialize( IArchive &ar )
{
StdString temp;
if(ar.IsReading())
{
ar.Read(temp, "LayerLink");
m_LayerLink = temp.c_str();
ar.Read(temp, "ModelName");
m_ModelName = temp.c_str();
ar.Read(m_XCoverage, "XCoverage");
ar.Read(m_YCoverage, "YCoverage");
ar.Read(m_XRandomness, "XRandomness");
ar.Read(m_YRandomness, "YRandomness");
ar.Read(m_MinScale, "MinScale");
ar.Read(m_MinScale, "MaxScale");
ar.Read(m_MinYaw, "MinYaw");
ar.Read(m_MaxYaw, "MaxYaw");
}
else
{
ar.Write(m_LayerLink.GetString(), "LayerLink");
ar.Write(m_ModelName.GetString(), "ModelName");
ar.Write(m_XCoverage, "XCoverage");
ar.Write(m_YCoverage, "YCoverage");
ar.Write(m_XRandomness, "XRandomness");
ar.Write(m_YRandomness, "YRandomness");
ar.Write(m_MinScale, "MinScale");
ar.Write(m_MinScale, "MaxScale");
ar.Write(m_MinYaw, "MinYaw");
ar.Write(m_MaxYaw, "MaxYaw");
}
}
示例3: UpdateWorldEventTrigger
void CWorldEventToolPal::UpdateWorldEventTrigger( void )
{
static DWORD msgHash_FindObject = CHashString(_T("FindObject")).GetUniqueID();
static DWORD msgHash_GetComponentType = CHashString(_T("GetComponentType")).GetUniqueID();
static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
static DWORD msgHash_SerializeObject = CHashString(_T("SerializeObject")).GetUniqueID();
static CHashString Hash_Type = CHashString(_T("CWorldEventTrigger"));
CString buf;
m_Name.GetLBText(m_Name.GetCurSel(), buf);
CHashString hszName((TCHAR*)buf.GetBuffer());
FINDOBJECTPARAMS param;
param.hszName = &hszName;
DWORD result = m_ToolBox->SendMessage(msgHash_FindObject, sizeof(FINDOBJECTPARAMS), ¶m);
// object exists
if( param.bFound == true )
{
GETCOMPONENTTYPEPARAMS gctp;
gctp.name = &hszName;
m_ToolBox->SendMessage(msgHash_GetComponentType, sizeof(gctp), &gctp);
// it is a world event, get values from it
if ( (gctp.componenttype != NULL) && (gctp.componenttype->GetUniqueID() == Hash_Type.GetUniqueID()) )
{
CREATEARCHIVE ca;
CHashString streamType(_T("Memory"));
ca.streamData = NULL;
ca.mode = STREAM_MODE_WRITE | STREAM_MODE_READ;
ca.streamType = &streamType;
m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca, NULL, NULL);
IArchive *MemArchive = (ca.archive);
MemArchive->SetIsWriting(true);
MemArchive->SeekTo(0);
SERIALIZEOBJECTPARAMS sop;
sop.name = &hszName;
sop.archive = MemArchive;
m_ToolBox->SendMessage(msgHash_SerializeObject, sizeof(SERIALIZEOBJECTPARAMS), &sop, NULL, NULL);
MemArchive->SetIsWriting(false);
MemArchive->SeekTo(0);
StdString tmp;
MemArchive->Read( tmp );
m_EntityName.SetWindowText( tmp.c_str() );
MemArchive->Read( tmp );
m_EntityType.SetWindowText( tmp.c_str() );
MemArchive->Read( tmp );
m_EventName.SetWindowText( tmp.c_str() );
MemArchive->Close();
}
}
}
示例4: CompareNames
bool CEntityManager::CompareNames(StdString searchString, StdString compString)
{
static StdString token(_T("\\"));
size_t subLen;
// if searchString is null, positive match w/ everything
if(_tcscmp(searchString, _T("")) == 0)
{
return true;
}
// if compString is null, no match
if(_tcscmp(compString, _T("")) == 0)
{
return false;
}
const TCHAR* searchStringArray = searchString.c_str();
const TCHAR* compStringArray = compString.c_str();
while( _tcscmp(searchStringArray, _T("")) != 0 )
{
subLen = _tcscspn(compStringArray, token); //length of substring to token
if (subLen > 0)
{
// compare substrings up to token
if( _tcsncmp(searchStringArray, compStringArray, subLen) == 0 )
{
return true;
}
// now check if compString's substring's next char is == token
if( compStringArray[subLen] != token.c_str()[0] )
{
// did not return above, therefore does not match
return false;
}
// continue...advance ptr
compStringArray = _tcsninc(compStringArray, subLen+1);
}
else
{
// string out
return false;
}
}
// if exited while loop..then true
return true;
}
示例5: SerializeRadioItem
void COptionTreeWrapper::SerializeRadioItem(IArchive &ar, COptionTreeItem *item, bool read)
{
StdString szVal;
COptionTreeItemRadio *otiRadio;
OT_RADIO_NODE *node;
int index;
otiRadio = dynamic_cast<COptionTreeItemRadio*>(item);
if (item == NULL)
{
//error
StdString error = _T("Could not cast item to COptionTreeItemRadio: ");
error += item->GetLabelText();
::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
return;
}
if (read)
{
ar.Read(szVal);
node = otiRadio->Node_FindNode(szVal.c_str());
if (node != NULL)
{
otiRadio->Node_UnCheckAll();
node->m_bChecked = true;
}
}
else
{
index = otiRadio->Node_GetChecked();
node = otiRadio->Node_FindNode(index);
ar.Write(node->m_strText);
}
}
示例6: CreateFile
StdString HashSHA1Impl::GetFileHash(StdString strFile)
{
StdString strRet;
HANDLE hFile = CreateFile(strFile.c_str(), GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
HANDLE hMapping = CreateFileMapping(hFile, NULL, PAGE_WRITECOPY, 0, 0, NULL);
if (hMapping != INVALID_HANDLE_VALUE)
{
PBYTE pByte = (PBYTE)MapViewOfFile(hMapping, FILE_MAP_COPY, 0, 0, 0);
unsigned long dwSize = GetFileSize(hFile, NULL);
Reset();
Input(pByte, dwSize);
unsigned int digest[5] = {0};
Result(digest);
TCHAR szRes[48] = _T("");
_sntprintf_s(szRes, 48, 48, _T("%x%x%x%x%x"),
digest[0], digest[1], digest[2], digest[3], digest[4]);
strRet = szRes;
UnmapViewOfFile(pByte);
CloseHandle(hMapping);
}
else
{
CloseHandle(hFile);
}
}
return strRet;
}
示例7: SerializeEditItemString
void COptionTreeWrapper::SerializeEditItemString(IArchive &ar, COptionTreeItem *item, bool read)
{
StdString szString;
COptionTreeItemEdit *otiEdit;
CString szItem;
otiEdit = dynamic_cast<COptionTreeItemEdit*>(item);
if(otiEdit == NULL)
{
//error
StdString error = _T("Could not cast item to COptionTreeItemEdit: ");
error += item->GetLabelText();
::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
return;
}
otiEdit->CreateEditItem(0, NULL);
if (read)
{
ar.Read(szString);
otiEdit->SetEditText(szString.c_str());
}
else
{
otiEdit->GetWindowText(szItem);
ar.Write(szItem);
}
}
示例8: CheckMouseState
DWORD CGUIItem::CheckMouseState(float mouseX, float mouseY, MOUSESTATE mouseState,
float x, float y, float width, float height, DWORD dwLastState)
{
DWORD btState;
if (mouseState == MOUSE_OPEN)
{
m_pVisItem->MouseOver(mouseX, mouseY, x, y, width, height, &btState);
return btState;
}
else if (mouseState == MOUSE_LEFTPRESSED)
{
m_pVisItem->MouseButton(mouseX, mouseY, true, false, x, y, width, height, &btState);
return btState;
}
else if (mouseState == MOUSE_LEFTRELEASED)
{
if ( m_pVisItem->MouseButton(mouseX, mouseY, false, true, x, y, width, height, &btState) )
{
StdString eventName = _T("RELEASED_");
eventName += GetName()->GetString();
CHashString eName(eventName.c_str());
GUIEVENT ge;
ge.event = eName.GetUniqueID();
ge.ar = NULL;
static DWORD msgHash_QueueGUIStateEvent = CHashString(_T("QueueGUIStateEvent")).GetUniqueID();
m_ToolBox->SendMessage(msgHash_QueueGUIStateEvent, sizeof(GUIEVENT), &ge);
}
return btState;
}
return 0;
}
示例9: SerializeStaticItemString
void COptionTreeWrapper::SerializeStaticItemString(IArchive &ar, COptionTreeItem *item, bool read)
{
StdString szString;
COptionTreeItemStatic *otiStatic = dynamic_cast<COptionTreeItemStatic*>(item);
CString szItem;
if(otiStatic == NULL)
{
//error
StdString error = _T("Could not cast item to COptionTreeItemStatic: ");
error += item->GetLabelText();
::MessageBox(NULL, error, _T("Invalid Command"), MB_OK);
return;
}
if(read)
{
ar.Read(szString);
otiStatic->SetStaticText(szString.c_str());
}
else
{
szItem = otiStatic->GetStaticText();
ar.Write(szItem);
}
}
示例10: DBReadString
void CSchemaItem::DBReadString( DATABASEDATA *value, IArchive *ar, const TCHAR *tag )
{
value->type = DBTYPE_STRING;
StdString szReadString;
ar->Read( szReadString );
value->AssignString( (TCHAR *)szReadString.c_str(), _tcslen(szReadString) );
}
示例11: OnLoadKeyBinding
DWORD CInputManager::OnLoadKeyBinding(DWORD msgSize, void *param)
{
IHashString *szhFileName;
VERIFY_MESSAGE_SIZE(msgSize, sizeof(IHashString*));
szhFileName = (IHashString*)param;
StdString szNodeName;
IXMLArchive *Archive;
CHashString streamType(_T("File"));
CREATEARCHIVE ca;
DWORD retVal = MSG_NOT_HANDLED;
ca.streamData = (void*)szhFileName->GetString();
ca.mode = STREAM_MODE_READ;
ca.streamType = &streamType;
// call the Archive factory to create an XML archive
static DWORD msgHash_CreateXMLArchive = CHashString(_T("CreateXMLArchive")).GetUniqueID();
if (retVal = m_ToolBox->SendMessage(msgHash_CreateXMLArchive, sizeof(CREATEARCHIVE), &ca) != MSG_HANDLED)
{
//log error
m_ToolBox->SetErrorValue(WARN_INVALID_OPERATION);
m_ToolBox->Log(LOGWARNING, _T("CInputManager: Could not create archive from: %s\n"), szhFileName->GetString());
return MSG_NOT_HANDLED;
}
Archive = dynamic_cast<IXMLArchive *>(ca.archive);
int num;
CHashString curKeyBind(_T(""));
StdString keybindName;
StdString parentType;
StdString childType;
StdString msg;
int key;
bool hitOnce;
Archive->GetNode(szNodeName);
Archive->Read(keybindName, _T("name"));
Archive->Read(num, _T("num"));
curKeyBind = keybindName.c_str();
while (num != 0)
{
Archive->Read( msg, _T("msg") );
Archive->Read( key, _T("key") );
Archive->Read( hitOnce, _T("hitOnce") );
//Add Entry to page
CHashString szMessage(msg);
KEYBINDINGMAP &curPage = m_KeyMap[ curKeyBind.GetUniqueID() ];
curPage[ key ].msg = szMessage.GetUniqueID();
curPage[ key ].hitOnce = hitOnce;
num--;
}
Archive->Close();
return MSG_HANDLED_STOP;
}
示例12: CreateRadioItem
void COptionTreeWrapper::CreateRadioItem(CHashString compName, ViewFormatObject *obj, COptionTreeItem* root)
{
IRadioViewObject *radioObject = dynamic_cast<IRadioViewObject*>(obj);
if(radioObject == NULL)
{
StdString error = _T("Could not cast to a CRadioViewObject");
::MessageBox(NULL, error, _T("Invalid Operaton"), MB_OK);
return;
}
StdString type = radioObject->GetBasicType();
StdString name = radioObject->GetName();
RADIOLIST *radioList = radioObject->GetRadioList();
StdString defSelect = radioObject->GetDefSelect();
StdString text;
bool checked;
// Create COptionTreeItem
COptionTreeItemRadio *otiRadio;
otiRadio = (COptionTreeItemRadio*)m_mTrees[compName.GetUniqueID()].m_Tree->InsertItem(new COptionTreeItemRadio(), root);
otiRadio->SetLabelText(name.c_str());
otiRadio->SetInfoText(_T(""));
otiRadio->CreateRadioItem();
if(radioList->size() > 0)
{
RADIOLIST::iterator rlIter = radioList->begin();
for(; rlIter != radioList->end(); rlIter++)
{
text = (*rlIter);
if ( _tcscmp(text, defSelect) == 0 )
{
checked = true;
}
else
{
checked = false;
}
otiRadio->InsertNewRadio(text.c_str(), checked);
}
}
}
示例13: OnAddZipFile
/// \brief message handler to create zipped memory stream
/// \param size - size of LPCTSTR
/// \param param - pointer to string with path
/// \return EE message return code
DWORD CZLibStreamFactory::OnAddZipFile(DWORD size, void *param)
{
VERIFY_MESSAGE_SIZE(size, sizeof(LPCTSTR));
StdString sPath = static_cast<LPCTSTR>(param);
sPath.MakeSafeFileName();
//sPath.ConformSlashesForward();
if (!CZipFileStream::AddSearchPath(sPath.c_str()))
{
return MSG_ERROR;
}
return MSG_HANDLED_STOP;
}
示例14: CreateComboItem
void COptionTreeWrapper::CreateComboItem(CHashString compName, ViewFormatObject *obj, COptionTreeItem* root)
{
IComboViewObject *comboObject = dynamic_cast<IComboViewObject*>(obj);
if(comboObject == NULL)
{
StdString error = _T("Could not cast to a CComboViewObject");
::MessageBox(NULL, error, _T("Invalid Operaton"), MB_OK);
return;
}
int index;
StdString type = comboObject->GetBasicType();
StdString name = comboObject->GetName();
StdString defSelect = comboObject->GetDefSelect();
// create COptionTreeItem
COptionTreeItemComboBox *otiCombo;
COMBOLIST *comboList;
comboList = comboObject->GetComboList();
otiCombo = (COptionTreeItemComboBox*)m_mTrees[compName.GetUniqueID()].m_Tree->InsertItem(new COptionTreeItemComboBox(), root);
otiCombo->SetLabelText(name.c_str());
if (otiCombo->CreateComboItem(CBS_SORT) == TRUE)
{
// if we got some options
if (comboList->size() > 0)
{
COMBOLIST::iterator clIter = comboList->begin();
// throw them in the combo box
for (; clIter != comboList->end(); clIter++)
{
otiCombo->AddString( (*clIter).c_str() );
}
}
}
index = otiCombo->FindStringExact(0, defSelect.c_str());
otiCombo->SetCurSel((index >= 0) ? index : 0);
}
示例15: LoadLinkMap
/// \brief Populate the LINKMAP from an XML file
/// \param fileName - The name of the XML file to load
void CEditorManager::LoadLinkMap( StdString &fileName )
{
CREATEARCHIVE ca;
IXMLArchive *ar;
IToolBox *toolBox = EngineGetToolBox();
StdString elementName;
StdString source;
StdString dest;
CHashString streamType(_T("File"));
ca.streamData = (void*)(fileName.c_str());
ca.mode = STREAM_MODE_READ;
ca.streamType = &streamType;
// Try opening the archive
static DWORD msgHash_CreateXMLArchive = CHashString(_T("CreateXMLArchive")).GetUniqueID();
if (toolBox->SendMessage(msgHash_CreateXMLArchive, sizeof(CREATEARCHIVE), &ca) != MSG_HANDLED)
{
std::string szText;
szText = "Failed to load xml format file: ";
szText += fileName;
::MessageBox(NULL, szText.c_str(), "Warning!", MB_OK|MB_ICONEXCLAMATION);
}
// Start reading from the archive
ar = dynamic_cast<IXMLArchive *>(ca.archive);
// skip the header info
ar->GetNode(elementName);
while (ar->GetNode(elementName))
{
if (elementName == _T("Link"))
{
ar->Read(source);
ar->Read(dest);
CHashString hashSrc(source);
CHashString hashDest(dest);
m_LinkMap.insert( LINKPAIR(hashDest.GetUniqueID(), hashSrc.GetUniqueID() ) );
}
}
ar->Close();
}