本文整理汇总了C++中Array::Alloc方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::Alloc方法的具体用法?C++ Array::Alloc怎么用?C++ Array::Alloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array::Alloc方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ArcCharToWide
// Convert archived names and comments to Unicode.
// Allows user to select a code page in GUI.
void ArcCharToWide(const char *Src,wchar *Dest,size_t DestSize,ACTW_ENCODING Encoding)
{
#if defined(_WIN_ALL) // Console Windows RAR.
if (Encoding==ACTW_UTF8)
UtfToWide(Src,Dest,DestSize);
else
{
Array<char> NameA;
if (Encoding==ACTW_OEM)
{
NameA.Alloc(DestSize+1);
IntToExt(Src,&NameA[0],NameA.Size());
Src=&NameA[0];
}
CharToWide(Src,Dest,DestSize);
}
#else // RAR for Unix.
if (Encoding==ACTW_UTF8)
UtfToWide(Src,Dest,DestSize);
else
CharToWide(Src,Dest,DestSize);
#endif
// Ensure that we return a zero terminate string for security reason.
// While [Jni]CharToWide might already do it, be protected in case of future
// changes in these functions.
if (DestSize>0)
Dest[DestSize-1]=0;
}
示例2: Save
void GPXRoute::Save(kGUITableObj *table,kGUITickBoxObj *draw,kGUIComboBoxObj *color)
{
unsigned int e;
unsigned int nr;
kGUIObj *obj;
GPXRow *row;
GPXRouteEntry *re;
/* delete old entries if there are any? */
for(e=0;e<m_numentries;++e)
delete m_entries.GetEntry(e);
SetDraw(draw->GetSelected());
SetColorIndex(color->GetSelection());
nr=table->GetNumChildren(0);
/* number of valid entries */
m_numentries=nr;
m_entries.Alloc(nr);
for(e=0;e<nr;++e)
{
obj=table->GetChild(e);
row=static_cast<GPXRow *>(obj);
re=new GPXRouteEntry();
re->m_wptname.SetString(row->GetWptName());
m_entries.SetEntry(e,re);
}
}
示例3: ReadCommentData
int Archive::ReadCommentData(Array<byte> &CmtData)
{
bool Unicode=SubHead.SubFlags & SUBHEAD_FLAGS_CMT_UNICODE;
if (!ReadSubData(&CmtData,NULL))
return(0);
int CmtSize=CmtData.Size();
if (Unicode)
{
CmtSize/=2;
Array<wchar> CmtDataW(CmtSize+1);
RawToWide(&CmtData[0],&CmtDataW[0],CmtSize);
CmtDataW[CmtSize]=0;
CmtData.Alloc(CmtSize*2);
WideToChar(&CmtDataW[0],(char *)&CmtData[0]);
CmtSize=strlen((char *)&CmtData[0]);
CmtData.Alloc(CmtSize);
}
return(CmtSize);
}
示例4: ParseCommandLine
void CommandData::ParseCommandLine(bool Preprocess,int argc, char *argv[])
{
*Command=0;
NoMoreSwitches=false;
#ifdef CUSTOM_CMDLINE_PARSER
// In Windows we may prefer to implement our own command line parser
// to avoid replacing \" by " in standard parser. Such replacing corrupts
// destination paths like "dest path\" in extraction commands.
// Also our own parser is Unicode compatible.
const wchar *CmdLine=GetCommandLine();
wchar *Par;
for (bool FirstParam=true;;FirstParam=false)
{
if ((CmdLine=AllocCmdParam(CmdLine,&Par))==NULL)
break;
if (!FirstParam) // First parameter is the executable name.
if (Preprocess)
PreprocessArg(Par);
else
ParseArg(Par);
free(Par);
}
#else
Array<wchar> Arg;
for (int I=1;I<argc;I++)
{
Arg.Alloc(strlen(argv[I])+1);
CharToWide(argv[I],&Arg[0],Arg.Size());
if (Preprocess)
PreprocessArg(&Arg[0]);
else
ParseArg(&Arg[0]);
}
#endif
if (!Preprocess)
ParseDone();
}
示例5: Clear
void Clear(size_t SubDataSize)
{
SubData.Alloc(SubDataSize);
Flags=LONG_BLOCK;
SubFlags=0;
}
示例6: GetComment
bool Archive::GetComment(Array<byte> &CmtData)
{
if (!MainComment)
return(false);
SaveFilePos SavePos(*this);
ushort CmtLength;
#ifndef SFX_MODULE
if (OldFormat)
{
Seek(SFXSize+SIZEOF_OLDMHD,SEEK_SET);
CmtLength=GetByte()+(GetByte()<<8);
}
else
#endif
{
if (NewMhd.Flags & MHD_COMMENT)
{
Seek(SFXSize+SIZEOF_MARKHEAD+SIZEOF_NEWMHD,SEEK_SET);
ReadHeader();
}
else
{
Seek(SFXSize+SIZEOF_MARKHEAD+NewMhd.HeadSize,SEEK_SET);
return(SearchSubBlock(SUBHEAD_TYPE_CMT)!=0 && ReadCommentData(CmtData)!=0);
}
#ifndef SFX_MODULE
if (CommHead.HeadCRC!=HeaderCRC)
{
Log(FileName,St(MLogCommHead));
Alarm();
return(false);
}
CmtLength=CommHead.HeadSize-SIZEOF_COMMHEAD;
#endif
}
#ifndef SFX_MODULE
if ((OldFormat && (OldMhd.Flags & MHD_PACK_COMMENT)) || (!OldFormat && CommHead.Method!=0x30))
{
if (!OldFormat && (CommHead.UnpVer < 15 || CommHead.UnpVer > UNP_VER || CommHead.Method > 0x35))
return(false);
ComprDataIO DataIO;
Unpack Unpack(&DataIO);
Unpack.Init();
DataIO.SetTestMode(true);
uint UnpCmtLength;
if (OldFormat)
{
UnpCmtLength=GetByte()+(GetByte()<<8);
CmtLength-=2;
DataIO.SetCmt13Encryption();
}
else
UnpCmtLength=CommHead.UnpSize;
DataIO.SetFiles(this,NULL);
DataIO.EnableShowProgress(false);
DataIO.SetPackedSizeToRead(CmtLength);
Unpack.SetDestSize(UnpCmtLength);
Unpack.DoUnpack(CommHead.UnpVer,false);
if (!OldFormat && ((~DataIO.UnpFileCRC)&0xffff)!=CommHead.CommCRC)
{
Log(FileName,St(MLogCommBrk));
Alarm();
return(false);
}
else
{
unsigned char *UnpData;
uint UnpDataSize;
DataIO.GetUnpackedData(&UnpData,&UnpDataSize);
CmtData.Alloc(UnpDataSize);
memcpy(&CmtData[0],UnpData,UnpDataSize);
}
}
else
{
CmtData.Alloc(CmtLength);
Read(&CmtData[0],CmtLength);
if (!OldFormat && CommHead.CommCRC!=(~CRC(0xffffffff,&CmtData[0],CmtLength)&0xffff))
{
Log(FileName,St(MLogCommBrk));
Alarm();
CmtData.Reset();
return(false);
}
}
#endif
#if defined(_WIN_32) && !defined(_WIN_CE) && !defined(_XBOX) && !defined(_LINUX)
//if (CmtData.Size()>0)
// OemToCharBuff((char*)&CmtData[0],(char*)&CmtData[0],CmtData.Size());
#endif
return(CmtData.Size()>0);
}