本文整理汇总了C++中ObjArray::addElement方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjArray::addElement方法的具体用法?C++ ObjArray::addElement怎么用?C++ ObjArray::addElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjArray
的用法示例。
在下文中一共展示了ObjArray::addElement方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mf_ReadFile
BObjectImp* FileAccessExecutorModule::mf_ReadFile()
{
const String* filename;
if (!getStringParam( 0, filename ))
return new BError( "Invalid parameter type" );
const Package* outpkg;
string path;
if (!pkgdef_split( filename->value(), exec.prog()->pkg, &outpkg, &path ))
return new BError( "Error in filename descriptor" );
if (path.find( ".." ) != string::npos)
return new BError( "No parent path traversal please." );
if (!HasReadAccess( exec.prog()->pkg, outpkg, path ))
return new BError( "Access denied" );
string filepath;
if (outpkg == NULL)
filepath = path;
else
filepath = outpkg->dir() + path;
ifstream ifs( filepath.c_str() );
if (!ifs.is_open())
return new BError( "File not found: " + filepath );
ObjArray* arr = new ObjArray();
string line;
while (getline(ifs, line))
arr->addElement( new String( line ) );
return arr;
}
示例2: mf_ListDirectory
BObjectImp* FileAccessExecutorModule::mf_ListDirectory()
{
const String* dirname;
const String* extension;
short listdirs;
if ((!getStringParam( 0, dirname )) ||
(!getStringParam( 1, extension )) ||
(!getParam( 2, listdirs )) )
return new BError( "Invalid parameter type" );
const Package* outpkg;
string path;
if (!pkgdef_split( dirname->value(), exec.prog()->pkg, &outpkg, &path ))
return new BError( "Error in dirname descriptor" );
if (path.find( ".." ) != string::npos)
return new BError( "No parent path traversal please." );
if (outpkg != NULL)
path = outpkg->dir() + path;
path = normalized_dir_form(path);
if ( !IsDirectory( path.c_str() ) )
return new BError( "Directory not found." );
bool asterisk = false;
bool nofiles = false;
if ( extension->getStringRep().find('*',0) != string::npos)
asterisk = true;
else if ( extension->length() == 0 )
nofiles = true;
ObjArray* arr = new ObjArray;
for( DirList dl( path.c_str() ); !dl.at_end(); dl.next() )
{
string name = dl.name();
if (name[0] == '.')
continue;
if ( IsDirectory( (path+name).c_str() ) )
{
if ( listdirs == 0 )
continue;
}
else if ( nofiles )
continue;
else if (!asterisk)
{
string::size_type extensionPointPos = name.rfind('.');
if (extensionPointPos == string::npos)
continue;
if (name.substr(extensionPointPos + 1) != extension->value())
continue;
}
arr->addElement( new String(name) );
}
return arr;
}
示例3: mf_ListGuilds
/// uo.em functions:
/// ListGuilds(); // returns an array of Guild objects
BObjectImp* GuildExecutorModule::mf_ListGuilds()
{
ObjArray* result = new ObjArray;
for( Guilds::iterator itr = guilds.begin(); itr != guilds.end(); ++itr )
{
Guild* guild = (*itr).second.get();
result->addElement( new EGuildRefObjImp( GuildRef(guild )) );
}
return result;
}
示例4: mf_Packages
BObjectImp* PolSystemExecutorModule::mf_Packages()
{
ObjArray* arr = new ObjArray;
for( unsigned i = 0; i < packages.size(); ++i )
{
PackageObjImp* imp = new PackageObjImp( PackagePtrHolder( packages[i] ) );
arr->addElement( imp );
}
return arr;
}
示例5: get_member_id
BObjectRef EGuildRefObjImp::get_member_id( const int id ) //id test
{
if (obj_->_disbanded)
return BObjectRef( new BError( "Guild has disbanded" ) );
ObjArray* arr;
switch(id)
{
case MBR_MEMBERS:
arr = new ObjArray;
for( SerialSet::iterator itr = obj_->_member_serials.begin();
itr != obj_->_member_serials.end();
/* do this earlier */)
{
unsigned long mserial = (*itr);
SerialSet::iterator last_itr = itr;
++itr;
Character* chr = system_find_mobile( mserial );
if (chr != NULL)
{
arr->addElement( new EOfflineCharacterRefObjImp( chr ) );
}
else
{
obj_->_member_serials.erase( last_itr );
}
}
return BObjectRef( arr );
case MBR_ALLYGUILDS:
arr = new ObjArray;
for( SerialSet::iterator itr = obj_->_allyguild_serials.begin();
itr != obj_->_allyguild_serials.end();
/* do this earlier */)
{
unsigned long gserial = (*itr);
SerialSet::iterator last_itr = itr;
++itr;
Guild* guild = FindGuild( gserial );
if (guild != NULL)
{
arr->addElement( new EGuildRefObjImp( ref_ptr<Guild>(guild) ) );
}
else
{
obj_->_allyguild_serials.erase( last_itr );
}
}
return BObjectRef( arr );
case MBR_ENEMYGUILDS:
arr = new ObjArray;
for( SerialSet::iterator itr = obj_->_enemyguild_serials.begin();
itr != obj_->_enemyguild_serials.end();
/* do this earlier */)
{
unsigned long gserial = (*itr);
SerialSet::iterator last_itr = itr;
++itr;
Guild* guild = FindGuild( gserial );
if (guild != NULL)
{
arr->addElement( new EGuildRefObjImp( ref_ptr<Guild>(guild) ) );
}
else
{
obj_->_enemyguild_serials.erase( last_itr );
}
}
return BObjectRef( arr );
case MBR_GUILDID:
return BObjectRef( new BLong( obj_->_guildid ) );
default:
return BObjectRef( UninitObject::create() );
}
}