本文整理汇总了C++中BTranslatorRoster::Identify方法的典型用法代码示例。如果您正苦于以下问题:C++ BTranslatorRoster::Identify方法的具体用法?C++ BTranslatorRoster::Identify怎么用?C++ BTranslatorRoster::Identify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTranslatorRoster
的用法示例。
在下文中一共展示了BTranslatorRoster::Identify方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: file
// Function taken from Haiku ShowImage,
// function originally written by Michael Pfeiffer
bool
SlideShowSaver::IsImage(const entry_ref *pref)
{
if (!pref)
return false;
if (ent_is_dir(pref) != B_OK)
// if ref is erroneous or a directory, return false
return false;
BFile file(pref, B_READ_ONLY);
if (file.InitCheck() != B_OK)
return false;
BTranslatorRoster *proster = BTranslatorRoster::Default();
if (!proster)
return false;
BMessage ioExtension;
if (ioExtension.AddInt32("/documentIndex", 1) != B_OK)
return false;
translator_info info;
memset(&info, 0, sizeof(translator_info));
if (proster->Identify(&file, &ioExtension, &info, 0, NULL,
B_TRANSLATOR_BITMAP) != B_OK)
return false;
return true;
}
示例2: file
void
ResView::AddResource(const entry_ref &ref)
{
BFile file(&ref, B_READ_ONLY);
if (file.InitCheck() != B_OK)
return;
BString mime;
file.ReadAttrString("BEOS:TYPE", &mime);
if (mime == "application/x-be-resource") {
BMessage msg(B_REFS_RECEIVED);
msg.AddRef("refs", &ref);
be_app->PostMessage(&msg);
return;
}
type_code fileType = 0;
BTranslatorRoster *roster = BTranslatorRoster::Default();
translator_info info;
if (roster->Identify(&file, NULL, &info, 0, mime.String()) == B_OK)
fileType = info.type;
else
fileType = B_RAW_TYPE;
int32 lastID = -1;
for (int32 i = 0; i < fDataList.CountItems(); i++) {
ResourceData *resData = (ResourceData*)fDataList.ItemAt(i);
if (resData->GetType() == fileType && resData->GetID() > lastID)
lastID = resData->GetID();
}
off_t fileSize;
file.GetSize(&fileSize);
if (fileSize < 1)
return;
char *fileData = (char *)malloc(fileSize);
file.Read(fileData, fileSize);
ResourceData *resData = new ResourceData(fileType, lastID + 1, ref.name,
fileData, fileSize);
fDataList.AddItem(resData);
ResDataRow *row = new ResDataRow(resData);
fListView->AddRow(row);
SetSaveStatus(FILE_DIRTY);
}
示例3: sizeof
status_t
PictureView::_LoadPicture(const entry_ref* ref)
{
BFile file;
status_t status = file.SetTo(ref, B_READ_ONLY);
if (status != B_OK)
return status;
off_t fileSize;
status = file.GetSize(&fileSize);
if (status != B_OK)
return status;
// Check that we've at least some data to translate...
if (fileSize < 1)
return B_OK;
translator_info info;
memset(&info, 0, sizeof(translator_info));
BMessage ioExtension;
BTranslatorRoster* roster = BTranslatorRoster::Default();
if (roster == NULL)
return B_ERROR;
status = roster->Identify(&file, &ioExtension, &info, 0, NULL,
B_TRANSLATOR_BITMAP);
BBitmapStream stream;
if (status == B_OK) {
status = roster->Translate(&file, &info, &ioExtension, &stream,
B_TRANSLATOR_BITMAP);
}
if (status != B_OK)
return status;
BBitmap* picture = NULL;
if (stream.DetachBitmap(&picture) != B_OK
|| picture == NULL)
return B_ERROR;
// Remember image format so we could store using the same
fPictureMIMEType = info.MIME;
fPictureType = info.type;
_SetPicture(picture);
return B_OK;
}
示例4: Load
void PDocument::Load(void)
{
TRACE();
status_t err = B_OK;
BFile *file = new BFile(entryRef,B_READ_ONLY);
BMessage *node = NULL;
BTranslatorRoster *roster = NULL;
BMallocIO *output = new BMallocIO();
BMessage *loaded = new BMessage();
int32 i = 0;
translator_info *indentifed = new translator_info;
bool locked = Lock();
if (file->InitCheck() == B_OK)
{
roster = BTranslatorRoster::Default();
roster->Identify(file,NULL,indentifed,P_C_DOCUMENT_RAW_TYPE );
err = roster->Translate(file,indentifed,NULL,output,P_C_DOCUMENT_RAW_TYPE);
//buffer = (void *)output->Buffer();
if (err == B_OK)
{
err = loaded->Unflatten(output);
printf("%s",strerror(err));
loaded->PrintToStream();
ResetModified();
}
}
else
//**error handling
;
//docloader handles the Format and Stuff also the input translation
PDocLoader *docLoader = new PDocLoader(this,loaded);
delete allNodes;
delete allConnections;
delete printerSetting;
delete selected;
allNodes = docLoader->GetAllNodes();
for (i = 0; i<allNodes->CountItems(); i++)
{
node=((BMessage*)allNodes->ItemAt(i));
node->AddPointer("ProjectConceptor::doc",this);
valueChanged->AddItem(node);
}
allConnections = docLoader->GetAllConnections();
for (i = 0; i<allConnections->CountItems(); i++)
{
node= (BMessage *)allConnections->ItemAt(i);
node->AddPointer("ProjectConceptor::doc",this);
valueChanged->AddItem(node);
}
selected = docLoader->GetSelectedNodes();
delete commandManager;
commandManager= new PCommandManager(this);
commandManager->SetMacroList(docLoader->GetMacroList());
commandManager->SetUndoList(docLoader->GetUndoList());
commandManager->SetUndoIndex(docLoader->GetUndoIndex());
// commandManager->LoadMacros(docLoader->GetCommandManagerMessage());
// commandManager->LoadUndo(docLoader->GetCommandManagerMessage());
SetPrintSettings( docLoader->GetPrinterSetting());
editorManager->BroadCast(new BMessage(P_C_VALUE_CHANGED));
if (locked)
Unlock();
}