当前位置: 首页>>代码示例>>C++>>正文


C++ wxString::Alloc方法代码示例

本文整理汇总了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();
}
开发者ID:Duion,项目名称:Torsion,代码行数:52,代码来源:AutoCompData.cpp

示例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;
}
开发者ID:BackupTheBerlios,项目名称:codelite-svn,代码行数:48,代码来源:fileutils.cpp


注:本文中的wxString::Alloc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。