本文整理汇总了C++中FileFormat类的典型用法代码示例。如果您正苦于以下问题:C++ FileFormat类的具体用法?C++ FileFormat怎么用?C++ FileFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleFileFormatsResponse
void ClientServer::handleFileFormatsResponse(FileFormats *response)
{
QSettings settings;
QStringList filters;
for (int i=0; i<response->formats_size(); i++)
{
FileFormat format = response->formats(i);
QString filter = tr("%1 (").arg(QString::fromStdString(format.name()));
for (int j=0; j<format.extension_size(); j++)
{
filter += tr("*.%1").arg(QString::fromStdString(format.extension(j)));
if (j != format.extension_size()-1)
filter += " ";
}
filter += ")";
filters << filter;
}
qDebug() << filters.join(";;");
QString dir = settings.value(lastOpenDirSettingPath()).toString();
FileDialog *remoteFileDialog = new FileDialog(m_channel, NULL,
QString("Remote File Dialog"), dir, filters.join(";;"));
connect(remoteFileDialog, SIGNAL(accepted()), this, SLOT(onAccepted()));
connect(remoteFileDialog, SIGNAL(finished(int)), this, SLOT(onFinished(int)));
remoteFileDialog->show();
delete response;
}
示例2:
Defaults::Defaults(void)
{
FileFormat *filef;
FSSpec fspec;
McoStatus status;
int magic_num;
int version;
Str255 def = MONACO_DEFAULT;
Str255 fold = MONACO_FOLDER;
// set factory defaults
printer_type = 1;
input_type = DT_None;
patch_format = 1;
port = 1;
// now try to load in the user defults
filef = new FileFormat;
ptocstr(def);
ptocstr(fold);
status = filef->openFilefromPref(&fspec,(char*)def,(char*)fold);
if (status != MCO_SUCCESS) goto bail;
status = filef->relRead(sizeof(int),(char*)&magic_num);
if (status != MCO_SUCCESS) goto bail;
if (magic_num != DEFAULTS_MAGIC_NUM) goto bail;
status = filef->relRead(sizeof(int),(char*)&version);
if (status != MCO_SUCCESS) goto bail;
if (version > DEFAULTS_VERSION) goto bail;
status = filef->relRead(sizeof(int),(char*)&printer_type);
if (status != MCO_SUCCESS) goto bail;
status = filef->relRead(sizeof(int),(char*)&input_type);
if (status != MCO_SUCCESS) goto bail;
status = filef->relRead(sizeof(int),(char*)&patch_format);
if (status != MCO_SUCCESS) goto bail;
status = filef->relRead(sizeof(int),(char*)&port);
if (status != MCO_SUCCESS) goto bail;
filef->closeFile();
bail:
delete filef;
}
示例3: TEST
TEST(FileFormatManagerTest, readFile)
{
FileFormat *format =
FileFormatManager::instance().newFormatFromIdentifier("Avogadro: CML");
EXPECT_TRUE(format != NULL);
if (!format)
return;
Molecule molecule;
format->readFile(std::string(AVOGADRO_DATA) + "/data/ethane.cml", molecule);
delete format;
format = NULL;
EXPECT_EQ(molecule.data("name").type(), Variant::String);
EXPECT_EQ(molecule.data("name").toString(), "Ethane");
EXPECT_EQ(molecule.data("inchi").type(), Variant::String);
EXPECT_EQ(molecule.data("inchi").toString(), "1/C2H6/c1-2/h1-2H3");
}
示例4: BuildFileOps
void BuildFileOps(OpRcPtrVec & ops,
const Config& config,
const ConstContextRcPtr & context,
const FileTransform& fileTransform,
TransformDirection dir)
{
std::string src = fileTransform.getSrc();
if(src.empty())
{
std::ostringstream os;
os << "The transform file has not been specified.";
throw Exception(os.str().c_str());
}
std::string filepath = context->resolveFileLocation(src.c_str());
CreateFileNoOp(ops, filepath);
FileFormat* format = NULL;
CachedFileRcPtr cachedFile;
GetCachedFileAndFormat(format, cachedFile, filepath);
if(!format)
{
std::ostringstream os;
os << "The specified file load ";
os << filepath << " appeared to succeed, but no format ";
os << "was returned.";
throw Exception(os.str().c_str());
}
if(!cachedFile.get())
{
std::ostringstream os;
os << "The specified file load ";
os << filepath << " appeared to succeed, but no cachedFile ";
os << "was returned.";
throw Exception(os.str().c_str());
}
format->BuildFileOps(ops,
config, context,
cachedFile, fileTransform,
dir);
}
示例5: load_palette
Palette* load_palette(const char *filename)
{
std::string ext = base::string_to_lower(base::get_file_extension(filename));
Palette* pal = NULL;
if (ext == "col") {
pal = doc::file::load_col_file(filename);
}
else if (ext == "gpl") {
pal = doc::file::load_gpl_file(filename);
}
else {
FileFormat* ff = FileFormatsManager::instance()->getFileFormatByExtension(ext.c_str());
if (ff->support(FILE_SUPPORT_LOAD)) {
FileOp* fop = fop_to_load_document(NULL, filename,
FILE_LOAD_SEQUENCE_NONE |
FILE_LOAD_ONE_FRAME);
if (fop && !fop->has_error()) {
fop_operate(fop, NULL);
fop_post_load(fop);
if (fop->document &&
fop->document->sprite() &&
fop->document->sprite()->getPalette(FrameNumber(0))) {
pal = new Palette(
*fop->document->sprite()->getPalette(FrameNumber(0)));
// TODO remove this line when support for palettes with less
// than 256 colors is added.
pal->resize(Palette::MaxColors);
}
delete fop->document;
fop_done(fop);
}
}
}
if (pal)
pal->setFilename(filename);
return pal;
}
示例6: Colin_Barfoot
/********************************************************************************************
> FormatEntry* FilterManager::FindFormatEntryFromName(const StringBase& FormatName) const
Author: Colin_Barfoot (Xara Group Ltd) <[email protected]>
Created: 10/12/96
Inputs: FormatName: The name of a FileFormat given in the FileFormat's constructor
which has subsequently been Added to this FilterManager.
Returns: A pointer to the FileFormat with the name given or NULL if none was found
Purpose: Finds the one & only FileFormat with the given FormatName
Used by Xtra's mainly
********************************************************************************************/
FormatEntry* FilterManager::FindFormatEntryFromName(const StringBase& FormatName) const
{
for (UINT32 index = 0; index < GetLastFormatID(); ++index)
{
FormatEntry* pFormatEntry = GetFormats()[index];
if (pFormatEntry != NULL)
{
FileFormat* pFormat = pFormatEntry->GetFormat();
if (pFormat->GetName() == FormatName)
{
return pFormatEntry;
}
}
else
{
// we'll ignore this one
}
}
return NULL;
}
示例7: save_palette
bool save_palette(const char *filename, Palette* pal)
{
std::string ext = base::string_to_lower(base::get_file_extension(filename));
bool success = false;
if (ext == "col") {
success = doc::file::save_col_file(pal, filename);
}
else if (ext == "gpl") {
success = doc::file::save_gpl_file(pal, filename);
}
else {
FileFormat* ff = FileFormatsManager::instance()->getFileFormatByExtension(ext.c_str());
if (ff->support(FILE_SUPPORT_SAVE)) {
app::Context tmpContext;
doc::Document* doc = tmpContext.documents().add(
16, 16, doc::ColorMode::INDEXED,
Palette::MaxColors);
Sprite* sprite = doc->sprite();
doc->sprite()->setPalette(pal, false);
LayerImage* layer = dynamic_cast<LayerImage*>(sprite->folder()->getFirstLayer());
Image* image = layer->getCel(FrameNumber(0))->image();
int x, y, c;
for (y=c=0; y<16; y++)
for (x=0; x<16; x++)
image->putPixel(x, y, c++);
doc->setFilename(filename);
success = (save_document(&tmpContext, doc) == 0);
doc->close();
delete doc;
}
}
return success;
}
示例8: bake
void Baker::bake(std::ostream & os) const
{
FileFormat* fmt = FormatRegistry::GetInstance().getFileFormatByName(getImpl()->formatName_);
if(!fmt)
{
std::ostringstream err;
err << "The format named '" << getImpl()->formatName_;
err << "' could not be found. ";
throw Exception(err.str().c_str());
}
try
{
fmt->Write(*this, getImpl()->formatName_, os);
}
catch(std::exception & e)
{
std::ostringstream err;
err << "Error baking " << getImpl()->formatName_ << ":";
err << e.what();
throw Exception(err.str().c_str());
}
//
// TODO:
//
// - throw exception when we don't have inputSpace and targetSpace
// at least set
// - check limits of shaper and target, throw exception if we can't
// write that much data in x format
// - check that the shaper is 1D transform only, throw excpetion
// - check the file format supports shapers, 1D and 3D
// - add some checks to make sure we are monotonic
// - deal with the case of writing out non cube formats (1D only)
// - do a compare between ocio transform and output lut transform
// throw error if we going beyond tolerance
//
}
示例9: sameEncoding
bool sameEncoding(const FileFormat & src, const FileFormat & tgt)
{
if (src.equals(tgt))
return true;
switch (src.type)
{
case FFTutf8n:
return (tgt.type == FFTutf8);
case FFTutf16be:
return (tgt.type == FFTutf16);
case FFTutf32be:
return (tgt.type == FFTutf32);
}
return false;
}
示例10: removeFormat
bool FileFormatManager::removeFormat(const std::string &identifier)
{
FormatIdVector ids = m_identifiers[identifier];
m_identifiers.erase(identifier);
if (ids.empty())
return false;
for (FormatIdVector::const_iterator it = ids.begin(), itEnd = ids.end();
it != itEnd; ++it) {
FileFormat *fmt = m_formats[*it];
if (fmt == NULL)
continue;
removeFromMap(m_mimeTypes, fmt->mimeTypes(), *it);
removeFromMap(m_fileExtensions, fmt->fileExtensions(), *it);
m_formats[*it] = NULL;
delete fmt;
}
return true;
}
示例11: processPartitionCommand
bool processPartitionCommand(ISocket * masterSocket, MemoryBuffer & msg, MemoryBuffer & results)
{
FileFormat srcFormat;
FileFormat tgtFormat;
unsigned whichInput;
RemoteFilename fullPath;
offset_t totalSize;
offset_t thisOffset;
offset_t thisSize;
unsigned thisHeaderSize;
unsigned numParts;
bool compressedInput = false;
unsigned compatflags = 0;
srcFormat.deserialize(msg);
tgtFormat.deserialize(msg);
msg.read(whichInput);
fullPath.deserialize(msg);
msg.read(totalSize);
msg.read(thisOffset);
msg.read(thisSize);
msg.read(thisHeaderSize);
msg.read(numParts);
if (msg.remaining())
msg.read(compressedInput);
if (msg.remaining())
msg.read(compatflags); // not yet used
StringAttr decryptkey;
if (msg.remaining())
msg.read(decryptkey);
if (msg.remaining())
{
srcFormat.deserializeExtra(msg, 1);
tgtFormat.deserializeExtra(msg, 1);
}
StringBuffer text;
fullPath.getRemotePath(text);
LOG(MCdebugProgress, unknownJob, "Process partition %d(%s)", whichInput, text.str());
Owned<IFormatProcessor> processor = createFormatProcessor(srcFormat, tgtFormat, true);
Owned<IOutputProcessor> target = createOutputProcessor(tgtFormat);
processor->setTarget(target);
processor->setPartitionRange(totalSize, thisOffset, thisSize, thisHeaderSize, numParts);
processor->setSource(whichInput, fullPath, compressedInput, decryptkey);
processor->calcPartitions(NULL);
PartitionPointArray partition;
processor->getResults(partition);
serialize(partition, results);
return true;
}
示例12: Save
McoStatus PrinterType::Save(FSSpec *fspec)
{
int i;
McoStatus status = MCO_SUCCESS;
FileFormat *filef;
int magic_num = PRINTERTYPE_MAGICNUM;
int version = PRINTERTYPE_VERSION;
filef = new FileFormat;
// status = filef->createFilewithtype(fspec,smSystemScript,'Mprn','MCO6');
// if (status != MCO_SUCCESS) goto bail;
status = filef->openFile(fspec);
if (status != MCO_SUCCESS) goto bail;
status = filef->relWrite(sizeof(int),(char*)&magic_num);
if (status != MCO_SUCCESS) goto bailclose;
status = filef->relWrite(sizeof(int),(char*)&version);
if (status != MCO_SUCCESS) goto bailclose;
status = filef->relWrite(sizeof(ConData),(char*)&data);
if (status != MCO_SUCCESS) goto bailclose;
status = filef->relWrite(sizeof(int),(char*)&num_hands);
if (status != MCO_SUCCESS) goto bailclose;
status = filef->relWrite(sizeof(double)*31,(char*)x_hands);
if (status != MCO_SUCCESS) goto bailclose;
status = filef->relWrite(sizeof(double)*31,(char*)y_hands);
if (status != MCO_SUCCESS) goto bailclose;
status = filef->relWrite(sizeof(int),(char*)&sim_num);
if (status != MCO_SUCCESS) goto bailclose;
status = filef->relWrite(sizeof(int),(char*)&num_tweaks);
if (status != MCO_SUCCESS) goto bailclose;
for (i=0; i<num_tweaks; i++)
{
status = filef->relWrite(sizeof(Tweak_Element),(char*)tweaks[i]);
if (status != MCO_SUCCESS) goto bailclose;
}
filef->setInfo(fspec,MONACO_SIG,'MCO6');
bailclose:
filef->closeFile();
bail:
delete filef;
return status;
}
示例13: UIObject
FileFormatInstance::FileFormatInstance( const FileFormat& fmt ) :
UIObject( (*API->FileFormat->CreateFileFormatInstance)( ModuleHandle(), fmt.Handle() ) )
{
if ( IsNull() )
throw APIFunctionError( "CreateFileFormatInstance" );
}
示例14: FileDialog_import
void FileDialog_import(EditorState *state)
{
std::string path = getSaveLoadDirectory(state->settings->get("save_directory"),
state->isInstalled);
const char* filters[] = {"*.nbe"};
const char *cfile = tinyfd_openFileDialog("Import Nodes",
path.c_str(), 1, filters, 0);
if (!cfile)
return;
std::string file = cfile;
if (file == "")
return;
std::cerr << file.c_str() << std::endl;
// Get file parser
FileFormat *parser = getFromType(FILE_FORMAT_NBE, state);
if (!parser) {
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"File format does not exist.");
return;
}
// Get directory, and load
std::cerr << "Reading from " << file << std::endl;
Project *tmp = parser->read(file, state->project);
if (tmp) {
state->project->remesh();
} else {
switch(parser->error_code) {
case EFFE_IO_ERROR:
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"Failed to open the file\n\t(Does it not exist, or is it readonly?)");
break;
case EFFE_READ_OLD_VERSION:
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"This file is outdated and is not supported");
break;
case EFFE_READ_NEW_VERSION:
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"This file was created with a new version of NBE\n\t(Update your copy)");
break;
case EFFE_READ_PARSE_ERROR:
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"An error occurred while reading the file - it may be corrupted\n\t(This should never happen)");
break;
case EFFE_READ_WRONG_TYPE:
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"The file is not in the correct format\n\t(Are you opening the wrong type of file?)");
break;
default:
state->device->getGUIEnvironment()->addMessageBox(L"Unable to open",
L"Unknown error");
break;
}
delete parser;
parser = NULL;
}
}
示例15: GetPort
// The event handler for the main menu
McoStatus ToneTab::DoEvents(short item, Point clickPoint, WindowCode *wc, int32 *numwc, void **data,Boolean &changed)
{
int didit = 0;
int i,j;
McoStatus status = MCO_SUCCESS;
short item2 = item - startNum;
Str255 prompt;
StandardFileReply soutReply,sinReply;
Str255 outname = "\p";
SFTypeList filelist;
Str255 inname;
Rect r1;
short iType;
Handle iHandle;
WindowPtr oldP;
GetPort(&oldP);
SetPort( dp ) ;
// no codes passed back
*numwc = 0;
for (i=0; i<numControls; i++)
{
status = controls[i]->DoEvents(item,clickPoint,wc,numwc,data,changed,&didit);
if (status) return status;
if (changed)
{
doc->changedLinearTone = 1;
last_changed = 1;
CopyOutofControl(i);
CopyIntoControl(i);
}
else last_changed = 0;
if (didit) return status;
}
if (item2 == EXPORT)
{
if (doc->calCurves)
{
GetIndString(prompt,PROMPT_STRINGS,STANDARD_PROMPT);
StandardPutFile(prompt, outname, &soutReply);
if(soutReply.sfGood)
{
memcpy(outname, soutReply.sfFile.name, *(soutReply.sfFile.name)+1);
PathNameFromDirID(soutReply.sfFile.parID, soutReply.sfFile.vRefNum, outname);
ptocstr(outname);
status = doc->calCurves->exportTone((char*)outname);
if (status) McoErrorAlert(status);
else
{
FileFormat ff;
ff.setInfo(&soutReply.sfFile,MONACO_SIG,'TEXT');
}
}
}
}
else if (item2 == IMPORT)
{
if (doc->calCurves)
{
filelist[0] = 'TEXT';
StandardGetFile(0L, 1, filelist, &sinReply);
if(sinReply.sfGood)
{
memcpy(inname, sinReply.sfFile.name, *(sinReply.sfFile.name)+1);
PathNameFromDirID(sinReply.sfFile.parID, sinReply.sfFile.vRefNum, inname);
ptocstr(inname);
status = doc->calCurves->importTone((char*)inname);
if (status) McoErrorAlert(status);
else
{
CopyIntoControl(-1);
doc->changedLinearTone = 1;
}
status = MCO_SUCCESS;
}
}
}
else
{
GetDItem (dp, DESCRIPTION+startNum, &iType, (Handle*)&iHandle, &r1);
GetIText(iHandle,inname);
if (inname[0] > 100) inname[0] = 100;
ptocstr(inname);
strcpy(doc->printData->setting.toneDesc,(char*)inname);
}
SetPort(oldP);
return status;
}