本文整理汇总了C++中BoostPath类的典型用法代码示例。如果您正苦于以下问题:C++ BoostPath类的具体用法?C++ BoostPath怎么用?C++ BoostPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BoostPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: getChild
boost::any LuaGraphTreeModel::getChild(const boost::any& parent, const UInt32& index) const
{
try
{
BoostPath ThePath = boost::any_cast<BoostPath>(parent);
if(!ThePath.empty() &&
boost::filesystem::exists(ThePath))
{
boost::filesystem::directory_iterator end_iter;
UInt32 Count(0);
for ( boost::filesystem::directory_iterator dir_itr(ThePath); dir_itr != end_iter; ++dir_itr )
{
if( isValidFile(dir_itr->path()) )
{
if(Count == index)
{
return boost::any(dir_itr->path());
}
++Count;
}
}
}
return boost::any();
}
catch(boost::bad_any_cast &)
{
return boost::any();
}
}
示例4: BoostPath
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
}
}
示例5: SettingsFullPath
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);
}
示例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: InitialProjectFilePath
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);
}
}
示例8: open
bool VideoWrapper::open(const BoostPath& ThePath, Window* const TheWindow)
{
//Check if the file exists
if(boost::filesystem::exists(ThePath))
{
return open(ThePath.file_string(), TheWindow);
}
else
{
SWARNING << "VideoWrapper::open(): File " << ThePath.file_string() << " could not be opened, because no file with that path exists" << std::endl;
return false;
}
}
示例9: 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);
}
示例10: LeftName
bool MainApplication::CompLogFileDates::operator()(const BoostPath& Left, const BoostPath Right)
{
//Get the filenames
std::string LeftName(Left.stem());
std::string RightName(Right.stem());
//Convert the ISO formatted strings into time objects
boost::posix_time::ptime LeftTime(boost::posix_time::from_iso_string(LeftName));
boost::posix_time::ptime RightTime(boost::posix_time::from_iso_string(RightName));
//Return time comparison
//Oldest to Newest
return LeftTime < RightTime;
}
示例11: 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;
}
}
示例12: 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;
}
示例13: 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);
}
示例14: 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;
}
示例15: handleSaveButtonAction
void handleSaveButtonAction(ActionEventDetails* const details,
WindowEventProducer* const TutorialWindow,
TextEditor* const theTextEditor)
{
std::vector<WindowEventProducer::FileDialogFilter> Filters;
Filters.push_back(WindowEventProducer::FileDialogFilter("All","*"));
Filters.push_back(WindowEventProducer::FileDialogFilter("Lua Files","lua"));
BoostPath SavePath = TutorialWindow->saveFileDialog("Save File Window",
Filters,
std::string("newFile.lua"),
BoostPath(".."),
true);
if(SavePath.string() != "")
{
theTextEditor->saveFile(SavePath);
}
}