本文整理汇总了C++中XString类的典型用法代码示例。如果您正苦于以下问题:C++ XString类的具体用法?C++ XString怎么用?C++ XString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getFilenameExtension
XString getFilenameExtension(XString s)
{
int i = s.findRev('.');
s = s.mid(i + 1);
return s;
}
示例2: InitCommonControls
int GameLoop::InitInstance()
{
int code = App::InitInstance();
InitCommonControls();
//img_pacman = ImageList_LoadBitmap(App::GetInstance(), MAKEINTRESOURCE(IDB_BITMAP1),32, 0, RGB(255, 0, 255));
XString title;
title.LoadFromResource(IDS_APP_TITLE);
XString wclass;
wclass.LoadFromResource(IDC_OOPACMAN);
RECT rect = game->get_map()->get_rect();
DWORD style = WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME;
AdjustWindowRect(&rect, style, FALSE);
if (!window.CreateWnd(title,
style,
CW_USEDEFAULT, 0,
rect.right-rect.left, rect.bottom-rect.top,
NULL, LPCTSTR(NULL))
)
return 1;
SetMainWindow(&window);
window.ShowWindow(_cmdShow);
window.UpdateWindow();
return code;
}
示例3: error
/*
*******************************************************************
* Function: IGBLSMConfigurationAccess::RemoveCIS
*
* Description: Removes a CIS and all associated CIs from persistent storage.
*
*
* Parameters:
* CGBLCISID cisid
*
* Returns:
* CGBLCOError
*
*******************************************************************
*/
CGBLCOError IGBLSMConfigurationAccess::RemoveCIS( CGBLCISID cisid )
{
CGBLCOError error(CGBLCOError::EGBLCOErrorType::GBLCO_OK);
// Check we're actually connected to the server first...
if ( !(storageManager->IsConnected()) )
{
error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION_DESC, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION );
}
else
{
XString query;
XString dbName;
storageManager->GetDbName( dbName );
query << "DELETE FROM " << dbName << ".ciss WHERE ID=" << (int)cisid;
// Now execute it and check the response...
int queryResult = storageManager->ExecuteBlockingSQL( query.Str() );
if( queryResult != CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::NoResult )
{
error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_SQL_ERROR_DESC, GBLSM_ERROR_GENERAL_SQL_ERROR);
}
}
return error;
}
示例4: fname
//************************************
// Method: GetDocument
// FullName: vtPhysics::pFactory::GetDocument
// Access: public
// Returns: TiXmlDocument*
// Qualifier:
// Parameter: XString filename
//************************************
TiXmlDocument* pFactory::getDocument(XString filename)
{
XString fname(filename.Str());
if ( fname.Length() )
{
XString fnameTest = ResolveFileName(fname.CStr());
if ( fnameTest.Length())
{
TiXmlDocument* result = new TiXmlDocument(fnameTest.Str());
result->LoadFile(fnameTest.Str());
result->Parse(fnameTest.Str());
TiXmlNode* node = result->FirstChild( "vtPhysics" );
if (!node)
{
GetPMan()->m_Context->OutputToConsoleEx("PFactory : Couldn't load Document : %s",filename.Str());
return NULL;
}else
{
return result;
}
}
}
return NULL;
}
示例5: error
/*
*******************************************************************
* Function: IGBLSMLAEAccess::RemoveUser
*
* Description: Removes the association between a user and an LAE.
*
*
* Parameters:
* CGBLLAEID laeid
* CGBLUserID user
*
* Returns:
* CGBLCOError
*
*******************************************************************
*/
CGBLCOError IGBLSMLAEAccess::RemoveUser( CGBLLAEID laeid, CGBLUserID user )
{
CGBLCOError error(CGBLCOError::EGBLCOErrorType::GBLCO_OK);
// Check we're actually connected to the server first...
if ( !(storageManager->IsConnected()) )
{
error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION_DESC, GBLSM_ERROR_PROFILEACCESS_NO_CONNECTION );
}
else
{
XString query;
XString dbName;
// Get the name of the DB we're using
storageManager->GetDbName(dbName);
// Now build the query
query = "";
query << "DELETE FROM " << dbName << ".EventUsers WHERE LAEID=" << (int)laeid << " AND UserID=" << (int)user;
// Execute the query
int deleteResult = storageManager->ExecuteBlockingSQL( query.Str() );
if( deleteResult != CGBLSMStorageManager::EGBLStorageManagerExecutionStatus::NoResult )
{
error = CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL, GBLSM_ERROR_GENERAL_SQL_ERROR_DESC, GBLSM_ERROR_GENERAL_SQL_ERROR);
}
}
return error;
}
示例6: Add2
void Add2()
{
XString str = L"Hello";
str += L" ";
str += L"World";
wprintf(L"%s\n", str.GetString());
}
示例7: CGBLCOError
CGBLCOError
GBLCommon::ResourceTools::SaveObject(
CKBeObject*beo,
XString filename)
{
if (!beo)
{
return CGBLCOError(CGBLCOError::GBLCO_LOCAL,"Invalid Object",GBL_ERROR_ID_GBL_COMMON);
}
//todo : adding checks for saving ability
if(!filename.Length())
{
return CGBLCOError(CGBLCOError::GBLCO_LOCAL,"No path specified",GBL_ERROR_ID_GBL_COMMON);
}
CKERROR res = CK_OK;
CKObjectArray* oa = CreateCKObjectArray();
oa->InsertAt(beo->GetID());
res = beo->GetCKContext()->Save(filename.Str(),oa,0xFFFFFFFF,NULL);
DeleteCKObjectArray(oa);
return CGBLCOError(CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL,CKErrorToString(res),GBL_ERROR_ID_GBL_COMMON);
}
示例8: pWheelContactModify
void pWheel2::setWheelContactScript(int val)
{
CKBehavior * beh = (CKBehavior*)GetPMan()->GetContext()->GetObject(val);
if (!beh)
return;
XString errMessage;
if (!GetPMan()->checkCallbackSignature(beh,CB_OnWheelContactModify,errMessage))
{
xError(errMessage.Str());
return;
}
pCallbackObject::setWheelContactScript(val);
wheelContactModifyCallback = new pWheelContactModify();
wheelContactModifyCallback->setWheel(this);
getWheelShape()->setUserWheelContactModify((NxUserWheelContactModify*)wheelContactModifyCallback);
//----------------------------------------------------------------
//track information about callback
getBody()->getCallMask().set(CB_OnWheelContactModify,true);
}
示例9: SaveFile
BOOL MyAppWindow :: SaveFile( void )
{
XFile savefile;
XString s;
mle->GetText( &s );
/* now open the file, create a new one if the given filename is not existing, otherwise overwrite */
/* it. open the file for write-access, dont allow any other programm to use the file while it is open*/
if( savefile.Open( path, XFILE_CREATE_IF_NEW | XFILE_REPLACE_EXISTING, XFILE_SHARE_DENYNONE | XFILE_WRITEONLY, s.GetLength()) == 0)
{
/* set the file-cursor to the beginning of the file */
savefile.Seek( 0, FILE_BEGIN);
/*save the string */
savefile.Write ( (char*) s, s.GetLength());
/* close the file */
savefile.Close();
saved = TRUE;
return TRUE;
}
else
{
XMessageBox( "could not open file", "error", MB_OK| MB_ERROR);
return FALSE;
}
}
示例10: TimeDiff
void CGBLStorageManagerTestBBBase::StopAndShowTimeMeasure(ofstream &_trace, float &totalTime)
{
float executionTime = TimeDiff();
totalTime += executionTime;
XString disp = "";
disp << executionTime;
_trace << "Execution time: " << disp.Str() << " seconds" <<endl;
}
示例11: WBUF_STRING
inline
void WBUF_STRING(uint8_t *p, size_t pos, XString s, size_t len)
{
char *const begin = static_cast<char *>(WBUFP(p, pos));
char *const end = begin + len;
char *const mid = std::copy(s.begin(), s.end(), begin);
std::fill(mid, end, '\0');
}
示例12: WFIFO_STRING
inline
void WFIFO_STRING(int fd, size_t pos, XString s, size_t len)
{
char *const begin = static_cast<char *>(WFIFOP(fd, pos));
char *const end = begin + len;
char *const mid = std::copy(s.begin(), s.end(), begin);
std::fill(mid, end, '\0');
}
示例13: read_constdb
bool read_constdb(ZString filename)
{
io::ReadFile in(filename);
if (!in.is_open())
{
PRINTF("can't read %s\n"_fmt, filename);
return false;
}
bool rv = true;
AString line_;
while (in.getline(line_))
{
// is_comment only works for whole-line comments
// that could change once the Z dependency is dropped ...
LString comment = "//"_s;
XString line = line_.xislice_h(std::search(line_.begin(), line_.end(), comment.begin(), comment.end())).rstrip();
if (!line)
continue;
// "%m[A-Za-z0-9_] %i %i"
// TODO promote either qsplit() or asplit()
auto _it = std::find(line.begin(), line.end(), ' ');
auto name = line.xislice_h(_it);
auto _rest = line.xislice_t(_it);
while (_rest.startswith(' '))
_rest = _rest.xslice_t(1);
auto _it2 = std::find(_rest.begin(), _rest.end(), ' ');
auto val_ = _rest.xislice_h(_it2);
auto type_ = _rest.xislice_t(_it2);
while (type_.startswith(' '))
type_ = type_.xslice_t(1);
// yes, the above actually DTRT even for underlength input
int val;
int type = 0;
// Note for future archeaologists: this code is indented correctly
if (std::find_if_not(name.begin(), name.end(),
[](char c)
{
return ('0' <= c && c <= '9')
|| ('A' <= c && c <= 'Z')
|| ('a' <= c && c <= 'z')
|| (c == '_');
}) != name.end()
|| !extract(val_, &val)
|| (!extract(type_, &type) && type_))
{
PRINTF("Bad const line: %s\n"_fmt, line_);
rv = false;
continue;
}
P<str_data_t> n = add_strp(name);
n->type = type ? StringCode::PARAM : StringCode::INT;
n->val = val;
}
return rv;
}
示例14: LoadFile
/* load a file */
BOOL MyAppWindow :: LoadFile ( char * p)
{
// is there already a file loaded or has the user entered some text?
if(loaded == FALSE && saved == TRUE)
{
//no, we load the file in the window of the current thread
XFile loadfile;
/* now open the file, fail if given filename is not existing */
/* open the file for read-access, dont allow any other programm to use the file while it is open*/
if( loadfile.Open( p, XFILE_FAIL_IF_NEW | XFILE_OPEN_EXISTING, XFILE_SHARE_DENYWRITE | XFILE_READONLY ) == 0)
{
XString s;
loading = TRUE;
//how large is the file?
XFileInfo info;
loadfile.GetFileInfo( &info );
LONG size = info.GetFileSize();
//read the complete file
loadfile.Read ( (PVOID) s.GetBuffer(info.GetFileSize() + 1), size);
s.ReleaseBuffer( info.GetFileSize() );
//set the XString content to the mle
mle->SetText( s );
//dontïforget to close the file
loadfile.Close();
loaded = TRUE;
path = p;
mle->SetFocus();
GetText( &s );
s+= " - ";
s+= p;
SetText( s );
loading = FALSE;
return TRUE;
}
else
{
XMessageBox( p, "couldnït open File!", MB_OK|MB_ERROR);
return FALSE;
}
}
else
{
//there is a file loaded, or the user has entered some text, so
// we create a new window and load the file
// XResource res( IDM_MAIN, ((MyApp*) GetProcess())->GetResourceLibrary());
MyAppWindow * win = new MyAppWindow( IDM_MAIN );
win->LoadFile(p);
return TRUE;
}
}
示例15: getFilenameWithoutPathAndExtension
XString getFilenameWithoutPathAndExtension(XString s)
{
XString k = getFilenameWithoutPath(s);
int i = k.findRev('.');
k = k.left(i);
return k;
}