本文整理汇总了C++中FileLoader类的典型用法代码示例。如果您正苦于以下问题:C++ FileLoader类的具体用法?C++ FileLoader怎么用?C++ FileLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build
Gun* GunFactory::build(std::string const gunType, Ship* const ship, bool const isPlayer){
FileLoader loader;
std::map<std::string, XMLGunBlueprint> blueprints = loader.getGunBlueprints();
if ( blueprints.find(gunType) == blueprints.end()) {
std::runtime_error("Not an valid gun type");
}
XMLGunBlueprint blueprint = blueprints[gunType];
BulletFactory* bulletFactory = new BulletFactory(this->fWorld, ship, blueprint.bullets);
Gun* gun;
// The direction the gun is pointed to
if(isPlayer == true){
// The player is up
Direction direction("up");
gun = new Gun(ship, direction, bulletFactory, blueprint);
}else{
// Enemies are down
Direction direction("down");
gun = new Gun(ship, direction, bulletFactory, blueprint);
}
return gun;
}
示例2: unserializeItemNode
bool Container::unserializeItemNode(FileLoader& f, NODE node, PropStream& propStream)
{
bool ret = Item::unserializeItemNode(f, node, propStream);
if(ret){
unsigned long type;
NODE nodeItem = f.getChildNode(node, type);
while(nodeItem){
//load container items
if(type == OTBM_ITEM){
PropStream itemPropStream;
f.getProps(nodeItem, itemPropStream);
Item* item = Item::CreateItem(itemPropStream);
if(!item){
return false;
}
if(!item->unserializeItemNode(f, nodeItem, itemPropStream)){
return false;
}
addItem(item);
}
else /*unknown type*/
return false;
nodeItem = f.getNextNode(nodeItem, type);
}
return true;
}
return false;
}
示例3: unserializeItemNode
bool Container::unserializeItemNode(FileLoader& f, NODE node, PropStream& propStream)
{
if(!Item::unserializeItemNode(f, node, propStream))
return false;
uint32_t type;
for(NODE nodeItem = f.getChildNode(node, type); nodeItem; nodeItem = f.getNextNode(nodeItem, type))
{
//load container items
if(type != OTBM_ITEM)
return false;
PropStream itemPropStream;
f.getProps(nodeItem, itemPropStream);
Item* item = Item::CreateItem(itemPropStream);
if(!item)
return false;
if(!item->unserializeItemNode(f, nodeItem, itemPropStream))
return false;
addItem(item);
updateItemWeight(item->getWeight());
}
return true;
}
示例4: LoadDBFile
bool DBSystem::LoadDBFile()
{
do
{
char* pBuffer = NULL;
unsigned int iLength = 0;
if (!EngineSystem::LoadAppFile("resource/data/game.data", pBuffer, iLength))
{
LOGGERSYSTEM->LogFatal("Init DBSystem Failed, DB Data Invalid\n");
return false;
}
std::string buffer = "";
if (EngineSystem::IsAndroid480X800())
{
buffer = "d42fcd0a5e6145fd988b55dc0570bb82";
}
else
{
buffer = "3ecae97470b968ec37bb640246a425e9";
}
// 进行静态数据md5码校验
std::string md5Key = MD5Crypto::md5(pBuffer, iLength);
if (md5Key.compare(buffer) != 0)
{
delete []pBuffer;
LOGGERSYSTEM->LogFatal("Init DBSystem Failed, DB Data Invalid2\n");
return false;
}
// 保存到SD卡对应目录下面
std::string dbFile = EngineSystem::GetDocumentDir()+"game.db";
FileLoader loader;
if (!loader.load((char*)dbFile.c_str(), FileLoader::_TYPED_CLEAR_WRITE_))
{
loader.unload();
delete []pBuffer;
return false;
}
loader.write(pBuffer, iLength);
loader.unload();
delete []pBuffer;
int ret = sqlite3_open(dbFile.c_str(), &m_pSQLite);
if (ret != SQLITE_OK)
{
LOGGERSYSTEM->LogFatal("Init DBSystem Failed, DBFile=%s\n", dbFile.c_str());
return false;
}
return true;
}
while(false);
return false;
}
示例5: generate
void SimpleVolumeGenerator::generate( const FileLoader &loader,
const FieldSelector &selector,
CoordinateAdjuster &adjuster,
const ColorMap &colormap
) {
if( selector.getFieldNum() < 4 ) {
throw std::runtime_error("SimpleVolumeGenerator::4 indeces is needed at least.");
}
volume_->clear();
// setting coordinates range
const FileLoader::DataType &max_range = loader.getMaxRange();
const FileLoader::DataType &min_range = loader.getMinRange();
const double min_x = selector.getField( min_range, 0);
const double min_y = selector.getField( min_range, 1);
const double min_z = selector.getField( min_range, 2);
const double dist_x = selector.getField( max_range, 0) - min_x;
const double dist_y = selector.getField( max_range, 1) - min_y;
const double dist_z = selector.getField( max_range, 2) - min_z;
const double dist = std::max( dist_x, std::max( dist_y, dist_z ) );
const double max_x = min_x + dist;
const double max_y = min_y + dist;
const double max_z = min_z + dist;
adjuster.setRangeX( max_x, min_x );
adjuster.setRangeY( max_y, min_y );
adjuster.setRangeZ( max_z, min_z );
// setting volume data
for( FileLoader::DataContainerType::const_iterator it = loader.begin();
it != loader.end();
++it ) {
const FileLoader::DataType &data = *it;
const double raw_x = selector.getField( data, 0 );
const double raw_y = selector.getField( data, 1 );
const double raw_z = selector.getField( data, 2 );
const double x = adjuster.x(raw_x) * ( getVolume()->sizex() );
const double y = adjuster.y(raw_y) * ( getVolume()->sizey() );
const double z = adjuster.z(raw_z) * ( getVolume()->sizez() );
double r, g, b, a;
colormap.getColor( adjuster.x(raw_x), &r, &g, &b, &a );
setVolumeElement
(
x, y, z,
r * 255, g * 255, b * 255, a * 255);
}
}
示例6: main
int main(int argc, char **argv)
{
char Name = 'M';
std::string taq = "TaquinA5_2.txt";
if (argc == 3)
{
std::ifstream infile;
infile.open(argv[2]);
if (!infile.is_open())
{
std::cout << "Error: file <" << argv[2] << ">" << " not found" << std::endl;
return (-1);
}
infile.close();
taq = argv[2];
FileLoader F;
std::string S;
Puzzle P;
SolutionGenerator SG;
short unsigned int** Tab;
clock_t timeDeb, timeEnd;
std::list<Puzzle> OpenedList, ClosedList;
int x = 0, y = 0, fg = -42;
timeDeb = clock();
DisplayLogo();
F.LoadFile(taq.c_str(), S);
std::istringstream In(S);
P.SetAlgo(Name);
Tab = P.CreatePuzzle(S);
std::list<Puzzle>::iterator FirstPuzzle;
OpenedList.push_back(P);
while (fg != 0 && !OpenedList.empty())
{
FirstPuzzle = OpenedList.begin();
fg = Resume(FirstPuzzle, OpenedList, ClosedList, timeEnd);
ProcessUp(FirstPuzzle, OpenedList, ClosedList);
ProcessDown(FirstPuzzle, OpenedList, ClosedList);
ProcessRight(FirstPuzzle, OpenedList, ClosedList);
ProcessLeft(FirstPuzzle, OpenedList, ClosedList);
(*FirstPuzzle).ClearListTab();
ClosedList.push_back(*FirstPuzzle);
OpenedList.erase(FirstPuzzle);
}
if (fg != 0)
std::cout << "NO SOLUTION FOR THIS TAQUIN!!!" << std::endl;
std::cout << "CLOSED LIST NUMBER OF CONTENTS : \t\t[" << ClosedList.size() << "]"<< std::endl;
std::cout << "TIME ELAPSED : \t\t[" << static_cast<double>(timeEnd - timeDeb) << "] ms." << std::endl;
ShowNbMoves();
std::cout << "Cleaning..." << std::endl;
Clean(OpenedList, ClosedList);
std::cout << "Clean done" << std::endl;
}
return (0);
}
示例7: loadNext
void FileLoader::loadNext() {
if (_queue->queries >= _queue->limit) return;
for (FileLoader *i = _queue->start; i;) {
if (i->loadPart()) {
if (_queue->queries >= _queue->limit) return;
} else {
i = i->_next;
}
}
}
示例8: LoadSDFBuffer
void SDFShadowDemo::LoadSDFBuffer()
{
const std::wstring sdfFile = L"testScene.sdf";
FileLoader loader;
loader.Open(FileSystem::getSingleton().GetModelsFolder() + sdfFile);
auto ptr = loader.GetDataPtr();
std::string sdfText(ptr);
std::vector<std::string> lines;
pystring::splitlines(sdfText, lines);
std::string line0 = lines[0];
std::vector<std::string> line0Split;
pystring::split(line0, line0Split, " ");
m_sdfParams.x = strtof(line0Split[0].c_str(), 0);
m_sdfParams.y = strtof(line0Split[1].c_str(), 0);
m_sdfParams.z = strtof(line0Split[2].c_str(), 0);
m_sdfParams.w = strtof(lines[2].c_str(), 0);
std::string line1 = lines[1];
std::vector<std::string> line1Split;
pystring::split(line1, line1Split, " ");
m_sdfOrigin.x = strtof(line1Split[0].c_str(), 0);
m_sdfOrigin.y = strtof(line1Split[1].c_str(), 0);
m_sdfOrigin.z = strtof(line1Split[2].c_str(), 0);
const auto SDFCount = m_sdfParams.x * m_sdfParams.y * m_sdfParams.z;
for (auto i = 0; i < SDFCount; ++i)
{
f32 value = strtof(lines[3 + i].c_str(), 0);
m_sdf.push_back(value);
}
Texture3dConfigDX11 texConfig;
texConfig.SetDefaults();
texConfig.SetWidth(static_cast<u32>(m_sdfParams.x));
texConfig.SetHeight(static_cast<u32>(m_sdfParams.y));
texConfig.SetDepth(static_cast<u32>(m_sdfParams.z));
texConfig.SetFormat(DXGI_FORMAT_R32_FLOAT);
D3D11_SUBRESOURCE_DATA data;
data.pSysMem = &m_sdf[0];
data.SysMemPitch = static_cast<u32>(sizeof(f32) * m_sdfParams.x);
data.SysMemSlicePitch = static_cast<u32>(sizeof(f32) * m_sdfParams.x * m_sdfParams.y);
ShaderResourceViewConfigDX11 srvConfig;
srvConfig.SetFormat(DXGI_FORMAT_R32_FLOAT);
srvConfig.SetViewDimensions(D3D11_SRV_DIMENSION_TEXTURE3D);
D3D11_TEX3D_SRV srv;
srv.MostDetailedMip = 0;
srv.MipLevels = 1;
srvConfig.SetTexture3D(srv);
m_SDFTex3D = m_pRender->CreateTexture3D(&texConfig, &data, &srvConfig);
}
示例9: FileLoader
void Preprocessor::LoadFile(cc_string filename)
{
FileLoader * loader = new FileLoader(filename.c_str());
if (!loader->isLoad())
{
delete loader;
return ;
}
m_Tokenizer.Init(filename, loader);
}
示例10: unserializeItemNode
bool Container::unserializeItemNode(FileLoader& f, NODE node, PropStream& propStream)
{
bool ret = Item::unserializeItemNode(f, node, propStream);
if(ret){
unsigned long type;
NODE nodeItem = f.getChildNode(node, type);
while(nodeItem){
//load container items
if(type == OTBM_ITEM){
PropStream itemPropStream;
f.getProps(nodeItem, itemPropStream);
Item* item = Item::CreateItem(itemPropStream);
if(!item){
return false;
}
if(!item->unserializeItemNode(f, nodeItem, itemPropStream)){
return false;
}
addItem(item);
//deepness
if (item->getContainer()){
if (getParentContainer())
item->getContainer()->setDeepness(getDeepness() + 1);
else{ //we only update deepness when a container get inside of another, so it means that deepness is not updated
setDeepness(1);
item->getContainer()->setDeepness(2);
}
}
updateAmountOfItems(item->getTotalAmountOfItemsInside());
total_weight += item->getWeight();
if(Container* parent_container = getParentContainer()) {
parent_container->updateItemWeight(item->getWeight());
}
}
else /*unknown type*/
return false;
nodeItem = f.getNextNode(nodeItem, type);
}
return true;
}
return false;
}
示例11: loadFile
void loadFile(
FileLoader& loader,
std::string path,
std::function<void(std::string const&)> continuation)
{
loader.loadFile(path, continuation);
}
示例12: Exists
bool CachingFileLoader::Exists() {
if (exists_ == -1) {
lock_guard guard(backendMutex_);
exists_ = backend_->Exists() ? 1 : 0;
}
return exists_ == 1;
}
示例13: IsDirectory
bool CachingFileLoader::IsDirectory() {
if (isDirectory_ == -1) {
lock_guard guard(backendMutex_);
isDirectory_ = backend_->IsDirectory() ? 1 : 0;
}
return isDirectory_ == 1;
}
示例14:
SpriteFactory::SpriteFactory()
{
FileLoader loader;
// #ifdef _WIN32
// loader.setExtension(".dll");
// #else
loader.setExtension(".so");
//#endif
std::cout << "\033[34mLoad des libs Ships" << std::endl;
loader.runInDirectory("libs/ships/", this->_shipLibs);
std::cout << "Load des libs Weapons" << std::endl;
loader.runInDirectory("libs/weapons/", this->_weaponLibs);
std::cout << "Load des libs Decors" << std::endl;
loader.runInDirectory("libs/decors/", this->_decorLibs);
std::cout << "\033[39m";
}
示例15: loadFilePair
void loadFilePair(
FileLoader& loader,
std::string path1,
std::string path2,
std::function<void(std::string const&, std::string const&)> continuation)
{
loader.loadFiles(path1, path2, continuation);
}