本文整理汇总了C++中BinaryFile::Open方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryFile::Open方法的具体用法?C++ BinaryFile::Open怎么用?C++ BinaryFile::Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryFile
的用法示例。
在下文中一共展示了BinaryFile::Open方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenFile
BaseFile* FileInterface::OpenFile(const char* szFilename, EFileType eType, EFileFlags eFlags)
{
switch(eType)
{
case BINARY_FILE:
{
BinaryFile* pFile = new BinaryFile;
if(pFile)
{
GEN_RESULT res = pFile->Open(szFilename, eFlags);
if(RESULT_OK == res)
{
return (BaseFile*)pFile;
}
}
}
break;
case TEXT_FILE:
{
//TODO:
}
break;
default:
break;
}
return NULL;
}
示例2: Save
/**
*
* @author OLiver
*/
bool Savegame::Save(const std::string& filename)
{
BinaryFile file;
if(!file.Open(filename, OFM_WRITE))
return false;
bool ret = Save(file);
file.Close();
return ret;
}
示例3: Load
/**
*
* @author OLiver
*/
bool Savegame::Load(const std::string& filePath, const bool load_players, const bool load_sgd)
{
BinaryFile file;
if(!file.Open(filePath, OFM_READ))
return false;
bool ret = Load(file, load_players, load_sgd);
file.Close();
return ret;
}
示例4: ConvertToPyrosFormat
bool AssimpModelImporter::ConvertToPyrosFormat(const std::string &Filename)
{
BinaryFile *bin = new BinaryFile();
if (bin->Open(Filename.c_str(), 'w'))
{
// Save Materials
int32 materialsSize = materials.size();
bin->Write(&materialsSize, sizeof(int32));
for (std::vector<MaterialProperties>::iterator i=materials.begin();i!=materials.end();i++)
{
// Material ID
bin->Write(&(*i).id,sizeof(int32));
// Material Name
int32 nameSize = (*i).Name.size();
bin->Write(&nameSize,sizeof(int32));
if (nameSize>0)
bin->Write((*i).Name.c_str(),sizeof(char)*nameSize);
// Color
uchar Out = (uchar)(*i).haveColor;
bin->Write(&Out, sizeof(uchar));
bin->Write(&(*i).Color, sizeof(Vec4));
// Specular
Out = (uchar)(*i).haveSpecular;
bin->Write(&Out, sizeof(uchar));
bin->Write(&(*i).Specular, sizeof(Vec4));
// Ambient
Out = (uchar)(*i).haveAmbient;
bin->Write(&Out, sizeof(uchar));
bin->Write(&(*i).Ambient, sizeof(Vec4));
// Emissive
Out = (uchar)(*i).haveEmissive;
bin->Write(&Out, sizeof(uchar));
bin->Write(&(*i).Emissive, sizeof(Vec4));
// WireFrame
Out = (uchar)(*i).WireFrame;
bin->Write(&Out, sizeof(uchar));
// Twosided
Out = (uchar)(*i).Twosided;
bin->Write(&Out, sizeof(uchar));
// Opacity
bin->Write(&(*i).Opacity,sizeof(f32));
// Shininess
bin->Write(&(*i).Shininess,sizeof(f32));
// Shininess Strength
bin->Write(&(*i).ShininessStrength,sizeof(f32));
// Textures
// Color Map
Out = (uchar)(*i).haveColorMap;
bin->Write(&Out, sizeof(uchar));
int32 colorMapSize = (*i).colorMap.size();
bin->Write(&colorMapSize,sizeof(int32));
if (colorMapSize>0)
bin->Write((*i).colorMap.c_str(),sizeof(char)*colorMapSize);
// Specular Map
Out = (uchar)(*i).haveSpecularMap;
bin->Write(&Out, sizeof(uchar));
int32 specularMapSize = (*i).specularMap.size();
bin->Write(&specularMapSize,sizeof(int32));
if (specularMapSize>0)
bin->Write((*i).specularMap.c_str(),sizeof(char)*specularMapSize);
// Normal Map
Out = (uchar)(*i).haveNormalMap;
bin->Write(&Out, sizeof(uchar));
int32 normalMapSize = (*i).normalMap.size();
bin->Write(&normalMapSize,sizeof(int32));
if (normalMapSize>0)
bin->Write((*i).normalMap.c_str(),sizeof(char)*normalMapSize);
// Have Bones
Out = (uchar)(*i).haveBones;
bin->Write(&Out, sizeof(uchar));
}
// Skeleton
int32 skeletonSize = skeleton.size();
bin->Write(&skeletonSize,sizeof(int32));
if (skeletonSize>0)
{
// Write ids
//.........这里部分代码省略.........
示例5: Load
bool Savegame::Load(const std::string& filePath, const bool load_players, const bool load_sgd)
{
BinaryFile file;
return file.Open(filePath, OFM_READ) && Load(file, load_players, load_sgd);
}
示例6: Save
bool Savegame::Save(const std::string& filename)
{
BinaryFile file;
return file.Open(filename, OFM_WRITE) && Save(file);
}