本文整理汇总了C++中LLViewerTextEditor::exportBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ LLViewerTextEditor::exportBuffer方法的具体用法?C++ LLViewerTextEditor::exportBuffer怎么用?C++ LLViewerTextEditor::exportBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLViewerTextEditor
的用法示例。
在下文中一共展示了LLViewerTextEditor::exportBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveAs
// virtual
void LLPreviewNotecard::saveAs()
{
std::string default_filename("untitled.notecard");
const LLInventoryItem *item = getItem();
if(item)
{
// gAssetStorage->getAssetData(item->getAssetUUID(), LLAssetType::AT_NOTECARD, LLPreviewNotecard::gotAssetForSave, this, TRUE);
default_filename = LLDir::getScrubbedFileName(item->getName());
}
LLFilePicker& file_picker = LLFilePicker::instance();
if( !file_picker.getSaveFile( LLFilePicker::FFSAVE_NOTECARD, default_filename ) )
{
// User canceled or we failed to acquire save file.
return;
}
// remember the user-approved/edited file name.
std::string filename = file_picker.getFirstFile();
LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("Notecard Editor");
std::string buffer;
if (!editor->exportBuffer(buffer))
{
// FIXME: Notify the user!
return;
}
S32 size = buffer.length() + 1;
std::ofstream export_file(filename.c_str(), std::ofstream::binary);
export_file.write(buffer.c_str(), size);
export_file.close();
}
示例2: saveAs_continued
void LLPreviewNotecard::saveAs_continued(AIFilePicker* filepicker)
{
if (!filepicker->hasFilename())
return;
LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor");
std::string buffer;
if (editor && !editor->exportBuffer(buffer))
{
// FIXME: Notify the user!
return;
}
S32 size = buffer.length();
std::string filename = filepicker->getFilename();
std::ofstream export_file(filename.c_str(), std::ofstream::binary);
export_file.write(buffer.c_str(), size);
export_file.close();
}
示例3: saveIfNeeded
bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
{
if(!gAssetStorage)
{
llwarns << "Not connected to an asset storage system." << llendl;
return false;
}
LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor");
if (editor && !editor->isPristine())
{
// We need to update the asset information
LLTransactionID tid;
LLAssetID asset_id;
tid.generate();
asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
LLVFile file(gVFS, asset_id, LLAssetType::AT_NOTECARD, LLVFile::APPEND);
std::string buffer;
if (!editor->exportBuffer(buffer))
{
return false;
}
editor->makePristine();
S32 size = buffer.length() + 1;
file.setMaxSize(size);
file.write((U8*)buffer.c_str(), size);
const LLInventoryItem* item = getItem();
// save it out to database
if (item)
{
std::string agent_url = gAgent.getRegion()->getCapability("UpdateNotecardAgentInventory");
std::string task_url = gAgent.getRegion()->getCapability("UpdateNotecardTaskInventory");
if (mObjectUUID.isNull() && !agent_url.empty())
{
// Saving into agent inventory
mAssetStatus = PREVIEW_ASSET_LOADING;
setEnabled(FALSE);
LLSD body;
body["item_id"] = mItemUUID;
llinfos << "Saving notecard " << mItemUUID
<< " into agent inventory via " << agent_url << llendl;
LLHTTPClient::post(agent_url, body,
new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
}
else if (!mObjectUUID.isNull() && !task_url.empty())
{
// Saving into task inventory
mAssetStatus = PREVIEW_ASSET_LOADING;
setEnabled(FALSE);
LLSD body;
body["task_id"] = mObjectUUID;
body["item_id"] = mItemUUID;
llinfos << "Saving notecard " << mItemUUID << " into task "
<< mObjectUUID << " via " << task_url << llendl;
LLHTTPClient::post(task_url, body,
new LLUpdateTaskInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
}
else if (gAssetStorage)
{
LLSaveNotecardInfo* info = new LLSaveNotecardInfo(this, mItemUUID, mObjectUUID,
tid, copyitem);
gAssetStorage->storeAssetData(tid, LLAssetType::AT_NOTECARD,
&onSaveComplete,
(void*)info,
FALSE);
}
}
}
return true;
}