本文整理汇总了C++中wxString::Alloc方法的典型用法代码示例。如果您正苦于以下问题:C++ wxString::Alloc方法的具体用法?C++ wxString::Alloc怎么用?C++ wxString::Alloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxString
的用法示例。
在下文中一共展示了wxString::Alloc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildMemberList
int AutoCompData::BuildMemberList( const wxString& name, wxString& list ) const
{
// First find the object...
const AutoCompClass* found = FindClassOrObject( name );
if ( !found )
return 0;
// TODO: Should we add members of dupes?
// Now loop till we run out of base classes.
wxArrayString tempArray;
wxString temp;
size_t len = 0;
while ( found )
{
for ( int i=0; i < found->GetFunctions().GetCount(); i++ )
{
temp = found->GetFunctions()[i]->GetMethodName() + IDENT_FUNCTION;
len += temp.Len() + 1;
tempArray.Add( temp );
}
for ( int i=0; i < found->GetVars().GetCount(); i++ )
{
temp = found->GetVars()[i]->GetName() + IDENT_VAR;
len += temp.Len() + 1;
tempArray.Add( temp );
}
const wxString& base = found->GetBase();
if ( base.IsEmpty() )
break;
found = FindClassOrObject( base );
}
wxString last, member;
tempArray.Sort( CmpStringNoCase );
list.Alloc( len - 1 );
for ( int i=0; i < tempArray.GetCount(); i++ ) {
member = tempArray[i];
if ( member.CmpNoCase( last ) == 0 )
continue;
list.Append( member );
list.Append( ' ' );
last = member;
}
list.RemoveLast();
list.Shrink();
return (int)tempArray.GetCount();
}
示例2: file
bool FileUtils::ReadFileUTF8(const wxFileName &fn, wxString &data)
{
wxFFile file(fn.GetFullPath().GetData(), wxT("rb"));
if(file.IsOpened() == false)
{
// Nothing to be done
return false;
}
if( file.Length() <= 0){
return false;
}
if( file.Length() > 0 ){
data.Alloc(file.Length());
}
//read first two bytes to check if unicode detected
bool isUnic(false);
unsigned char bom[2];
if(file.Length() >= 2){
if(file.Read(bom, 2) == 2){
if(bom[0] == 0xFE && bom[1] == 0xFF){
//UTF16
isUnic = true;
}
}
}
size_t len(file.Length());
wxFileOffset off(0);
if( isUnic ){
//seek file to start to read the consumed two bytes
len -= 2;
off = 2;
}
file.Seek(off);
char *pdata = new char[len + 1];
file.Read(pdata, len);
pdata[len] = 0;
data = wxString::FromAscii(pdata);
file.Close();
delete [] pdata;
return true;
}