本文整理汇总了C++中BoostPath::string方法的典型用法代码示例。如果您正苦于以下问题:C++ BoostPath::string方法的具体用法?C++ BoostPath::string怎么用?C++ BoostPath::string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoostPath
的用法示例。
在下文中一共展示了BoostPath::string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createLuaActivity
FieldContainerTransitPtr LuaActivity::createLuaActivity( const BoostPath& FilePath )
{
LuaActivity* Result = LuaActivity::createEmpty();
FilePathAttachment::setFilePath(Result, FilePath);
std::ifstream TheFile;
TheFile.exceptions(std::fstream::failbit | std::fstream::badbit);
try
{
TheFile.open(FilePath.string().c_str());
if(TheFile)
{
std::ostringstream Code;
Code << TheFile.rdbuf();
TheFile.close();
Result->setCode(Code.str());
}
return FieldContainerTransitPtr(Result);
}
catch(std::fstream::failure &f)
{
SWARNING << "LuaActivity::createLuaActivity(): Error reading file" << FilePath.string() << ": " << f.what() << std::endl;
return FieldContainerTransitPtr(NULL);
}
}
示例2: writeXML
OSG_BEGIN_NAMESPACE
/***************************************************************************\
* Class variables *
\***************************************************************************/
/***************************************************************************\
* Class methods *
\***************************************************************************/
/***************************************************************************\
* Instance methods *
\***************************************************************************/
bool ApplicationSettings::writeXML(const BoostPath& FilePath)
{
try
{
boost::property_tree::xml_parser::write_xml(FilePath.string(),
_PropertyTree,
std::locale(),
boost::property_tree::xml_parser::xml_writer_make_settings<typename boost::property_tree::ptree::key_type::value_type>(' ', 4));
}
catch(std::exception& ex)
{
SWARNING << "Failed to write settings to file: " << FilePath.string()
<< ", error: " << ex.what() << std::endl;
return false;
}
return true;
}
示例3: forceRead
TableDOMTransitPtr TableFileHandlerBase::forceRead(const BoostPath& FilePath)
{
TableDOMRefPtr Result;
//Determine if the file exists
if(!boost::filesystem::exists(FilePath))
{
SWARNING << "TableFileHandlerBase::read(): " << FilePath.string() << " does not exists." << std::endl;
return TableDOMTransitPtr(NULL);
}
//Determine the file extension
std::string Extension(boost::filesystem::extension(FilePath));
boost::algorithm::trim_if(Extension,boost::is_any_of("."));
//Get the Parent Directory Path of the file
_RootFilePath = FilePath;
_RootFilePath.remove_leaf();
//Get the FileType of a "txt" file (Forcing the document to be opened as a txt file)
TableFileTypeP TheFileType(getFileType("csv", TableFileType::OSG_READ_SUPPORTED));
//Is that extension supported for reading
if(TheFileType == NULL)
{
SWARNING << "TableFileHandlerBase::read(): Cannot read Field Container file: " << FilePath.string() << ", because no File types support " << Extension << " extension." << std::endl;
return TableDOMTransitPtr(NULL);
}
else
{
//Open up the input stream of the file
std::ifstream InputStream(FilePath.string().c_str(), std::ios::binary);
if(!InputStream)
{
SWARNING << "TableFileHandlerBase::read(): Couldn't open input stream for file " << FilePath.string() << std::endl;
return TableDOMTransitPtr(NULL);
}
else
{
//Read from the input stream
startReadProgressThread(InputStream);
Result = TheFileType->read(InputStream, FilePath.string());
stopReadProgressThread();
InputStream.close();
}
}
return TableDOMTransitPtr(Result);
}
示例4: readXML
bool ApplicationSettings::readXML(const BoostPath& FilePath)
{
try
{
boost::property_tree::xml_parser::read_xml(FilePath.string(), _PropertyTree);
}
catch(std::exception& ex)
{
SWARNING << "Failed to read settings from file: " << FilePath.string()
<< ", error: " << ex.what() << std::endl;
return false;
}
return true;
}
示例5: execute
void SaveProjectAsCommand::execute(void)
{
std::vector<WindowEventProducer::FileDialogFilter> KEProjectFileFilters;
KEProjectFileFilters.push_back(WindowEventProducer::FileDialogFilter("Project File","xml"));
KEProjectFileFilters.push_back(WindowEventProducer::FileDialogFilter("All Files","*"));
//Project File
BoostPath InitialProjectFilePath(MainApplication::the()->getProject()->getFilePath());
if(!boost::filesystem::exists(InitialProjectFilePath))
{
const Char8* ProjectName(getName(MainApplication::the()->getProject()));
InitialProjectFilePath = BoostPath(std::string("./") +
( ProjectName ? ProjectName : "Project") +
".xml");
}
BoostPath ProjectFilePath;
ProjectFilePath = MainApplication::the()->getMainWindow()->saveFileDialog("Save Project As ...",KEProjectFileFilters,InitialProjectFilePath.filename(),InitialProjectFilePath.parent_path(), true);
if(!ProjectFilePath.empty())
{
if(ProjectFilePath.extension().empty())
{
ProjectFilePath = ProjectFilePath.string() + ".xml";
}
MainApplication::the()->saveProject(ProjectFilePath);
}
}
示例6: initializeLogging
void MainApplication::initializeLogging(BoostPath KELogFilePath)
{
if(_EnableLogging)
{
//Configure the LogBuffer
osgLogP->setLogType(LOG_BUFFER, true);
//Configure the LogBuffer
osgLogP->getLogBuf().setEnabled(true);
osgLogP->getLogBuf().setCallback(KELogBufferCallback);
if(_LogToFile)
{
//Make sure the directory is created
try
{
boost::filesystem::create_directories(KELogFilePath.parent_path());
}
catch(std::exception& ex)
{
SWARNING << "Failed to create directory: " << KELogFilePath.parent_path()
<< ", error: " << ex.what() << std::endl;
return;
}
//If the Log is to a file then set the filev
_LogFile.open(KELogFilePath.string().c_str());
}
}
else
{
//Disable all logging
osgLogP->setLogType(LOG_NONE, true);
}
}
示例7: handleSplitMenuAction
void LuaDebuggerInterface::handleSplitMenuAction(ActionEventDetails* const details)
{
try
{
std::string ValueString = boost::any_cast<std::string>(_SplitButton->getSelectionValue());
BoostPath IconPath;
if(ValueString.compare("Horizontal") == 0)
{
IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-left-right.png"));
_CodeTextArea->setIsSplit(true);
_CodeTextArea->setSplitOrientation(SplitPanel::HORIZONTAL_ORIENTATION);
}
else if(ValueString.compare("Vertical") == 0)
{
IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-top-bottom.png"));
_CodeTextArea->setIsSplit(true);
_CodeTextArea->setSplitOrientation(SplitPanel::VERTICAL_ORIENTATION);
}
else
{
IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-none.png"));
_CodeTextArea->setIsSplit(false);
}
_SplitButton->setImages(IconPath.string());
}
catch (boost::bad_lexical_cast &)
{
//Could not convert to string
}
}
示例8: loadSettings
void MainApplication::loadSettings(const BoostPath& SettingsFile)
{
ApplicationSettings LoadedSettings;
if(!boost::filesystem::exists(SettingsFile))
{
SWARNING << "Could not load Settings from: \""
<< SettingsFile.string() << "\" because that file does not exist." << std::endl;
}
else
{
BoostPath SettingsFullPath(SettingsFile);
if(!SettingsFile.is_complete() && !SettingsFile.has_root_directory())
{
SettingsFullPath = boost::filesystem::complete(SettingsFile);
}
SettingsFullPath.normalize();
SLOG << "Loading Settings from: " << SettingsFullPath.string() << std::endl;
LoadedSettings.readXML(SettingsFile);
}
//Apply default settings to any settings that are not defined in loaded settings files
applyDefaultSettings(LoadedSettings, false);
setSettings(LoadedSettings);
}
示例9: getFileType
FCFileTypeP FCFileHandlerBase::getFileType(const BoostPath& FilePath, UInt32 Flags)
{
//Determine the file extension
std::string Extension(boost::filesystem::extension(FilePath.string()));
boost::algorithm::trim_if(Extension,boost::is_any_of("."));
return getFileType(Extension, Flags);
}
示例10: writeXML
OSG_BEGIN_NAMESPACE
/***************************************************************************\
* Class variables *
\***************************************************************************/
/***************************************************************************\
* Class methods *
\***************************************************************************/
/***************************************************************************\
* Instance methods *
\***************************************************************************/
bool ApplicationSettings::writeXML(const BoostPath& FilePath)
{
//Make sure the directory is created
try
{
boost::filesystem::create_directories(FilePath.parent_path());
}
catch(std::exception& ex)
{
SWARNING << "Failed to create directory: " << FilePath.parent_path()
<< ", error: " << ex.what() << std::endl;
return false;
}
//Write the XML
try
{
boost::property_tree::xml_parser::write_xml(FilePath.string(),
_PropertyTree,
std::locale(),
boost::property_tree::xml_parser::xml_writer_make_settings<boost::property_tree::ptree::key_type::value_type>(' ', 4));
}
catch(std::exception& ex)
{
SWARNING << "Failed to write settings to file: " << FilePath.string()
<< ", error: " << ex.what() << std::endl;
return false;
}
return true;
}
示例11: saveTextFile
void ContentPanel::saveTextFile(BoostPath file)
{
std::ofstream _OutputFile((file.string()).c_str());
ScrollPanelRefPtr _ToBeSavedScrollPanel = dynamic_cast<ScrollPanel*>(_LeftTabPanel->getTabContents(_LeftTabPanel->getSelectedIndex()));
TextAreaRefPtr _ToBeSavedTextArea = dynamic_cast<TextArea*>(_ToBeSavedScrollPanel->getViewComponent());
std::string _TobeSavedText = _ToBeSavedTextArea->getText();
_OutputFile<<_TobeSavedText;
_OutputFile.close();
}
示例12: generateSplitOptionListComponent
ComponentTransitPtr LuaDebuggerInterface::generateSplitOptionListComponent(List* const Parent,
const boost::any& Value,
UInt32 Index,
bool IsSelected,
bool HasFocus)
{
ButtonRecPtr TheComponent = Button::create();
TheComponent->setBackgrounds(NULL);
TheComponent->setAlignment(Vec2f(0.0f,0.5f));
std::string ValueString;
try
{
ValueString = boost::any_cast<std::string>(Value);
BoostPath IconPath;
if(ValueString.compare("Horizontal") == 0)
{
IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-left-right.png"));
}
else if(ValueString.compare("Vertical") == 0)
{
IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-top-bottom.png"));
}
else
{
IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-none.png"));
}
TheComponent->setImages(IconPath.string());
}
catch (boost::bad_lexical_cast &)
{
//Could not convert to string
}
TheComponent->setText(ValueString);
if(IsSelected)
{
LineBorderRecPtr LabelBorder = LineBorder::create();
LabelBorder->setWidth(1.0f);
LabelBorder->setColor(Color4f(0.0f,0.0f,0.0f,1.0f));
TheComponent->setBorders(LabelBorder);
}
else
{
TheComponent->setBorders(NULL);
}
return ComponentTransitPtr(TheComponent);
}
示例13: write
bool FCFileHandlerBase::write(const FCPtrStore Containers, const BoostPath& FilePath, const FCFileType::FCTypeVector& IgnoreTypes, bool Compress)
{
//Determine the file extension
std::string Extension(boost::filesystem::extension(FilePath));
boost::algorithm::trim_if(Extension,boost::is_any_of("."));
_RootFilePath = FilePath;
_RootFilePath.remove_filename();
//Get the FileType for this extension
FCFileTypeP TheFileType(getFileType(Extension, FCFileType::OSG_WRITE_SUPPORTED));
//Is that extension supported for reading
if(TheFileType == NULL)
{
SWARNING << "FCFileHandlerBase::write(): Cannot write Field Container file: " << FilePath.string() << ", because no File types support " << Extension << " extension." << std::endl;
return false;
}
else
{
//Open up the input stream of the file
std::ofstream OutputStream(FilePath.string().c_str(), std::ios::binary);
if(!OutputStream)
{
SWARNING << "FCFileHandlerBase::write(): Couldn't open output stream for file " << FilePath.string() << std::endl;
return false;
}
else
{
bool Result;
Result = write(Containers, OutputStream, Extension, IgnoreTypes, Compress);
OutputStream.close();
return Result;
}
}
}
示例14: handleTreeNodeExport
void handleTreeNodeExport(ActionEventDetails* const details,
Tree* const editorTree)
{
boost::any SelectedComp(editorTree->getLastSelectedPathComponent());
//Get the tree selection
try
{
FieldContainerTreeModel::ContainerFieldIdPair ThePair(boost::any_cast<FieldContainerTreeModel::ContainerFieldIdPair>(SelectedComp));
if(ThePair._FieldID == 0 &&
ThePair._Container != NULL)
{
std::vector<WindowEventProducer::FileDialogFilter> ExportFileFilters;
ExportFileFilters.push_back(WindowEventProducer::FileDialogFilter("Field Container File","xml"));
ExportFileFilters.push_back(WindowEventProducer::FileDialogFilter("All Files","*"));
//Export File
BoostPath InitialFilePath("./Export.xml");
WindowEventProducer* MainWindow(editorTree->getParentWindow()->getParentDrawingSurface()->getEventProducer());
BoostPath ExportFilePath;
ExportFilePath =MainWindow->saveFileDialog("Save Field Container",
ExportFileFilters,
InitialFilePath.filename(),
InitialFilePath.parent_path(),
true);
if(!ExportFilePath.empty())
{
if(ExportFilePath.extension().empty())
{
ExportFilePath = ExportFilePath.string() + ".xml";
}
FCFileType::FCPtrStore Containers;
Containers.insert(ThePair._Container);
FCFileType::FCTypeVector IgnoreTypes;
FCFileHandler::the()->write(Containers,ExportFilePath,IgnoreTypes);
}
}
}
catch(boost::bad_any_cast &ex)
{
SWARNING << ex.what() << std::endl;
}
}
示例15: loadCreditsWindow
DialogWindowTransitPtr loadCreditsWindow(const BoostPath& WindowDefinitionFile)
{
FCFileType::FCPtrStore NewContainers;
NewContainers = FCFileHandler::the()->read(WindowDefinitionFile);
for(FCFileType::FCPtrStore::iterator Itor(NewContainers.begin()) ; Itor!= NewContainers.end() ; ++Itor)
{
if((*Itor)->getType() == DialogWindow::getClassType())
{
return DialogWindowTransitPtr(dynamic_pointer_cast<DialogWindow>(*Itor));
}
}
SFATAL << "Failed to load Builder Credits Window definition from file: " << WindowDefinitionFile.string() << std::endl;
return DialogWindowTransitPtr(NULL);
}