本文整理汇总了C++中Poco::Path方法的典型用法代码示例。如果您正苦于以下问题:C++ Poco::Path方法的具体用法?C++ Poco::Path怎么用?C++ Poco::Path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poco
的用法示例。
在下文中一共展示了Poco::Path方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compile
void compile(const std::string& path)
{
Page page;
FileInputStream srcStream(path);
PageReader pageReader(page, path);
pageReader.emitLineDirectives(_emitLineDirectives);
pageReader.parse(srcStream);
Path p(path);
config().setString("inputFileName", p.getFileName());
config().setString("inputFilePath", p.toString());
DateTime now;
config().setString("dateTime", DateTimeFormatter::format(now, DateTimeFormat::SORTABLE_FORMAT));
std::string clazz;
if (page.has("page.class"))
{
clazz = page.get("page.class");
p.setBaseName(clazz);
}
else
{
clazz = p.getBaseName() + "Handler";
clazz[0] = Poco::Ascii::toUpper(clazz[0]);
}
std::auto_ptr<CodeWriter> pCodeWriter(createCodeWriter(page, clazz));
if (!_outputDir.empty())
{
p = Path(_outputDir, p.getBaseName());
}
p.setExtension("cpp");
std::string implPath = p.toString();
std::string implFileName = p.getFileName();
if (!_headerOutputDir.empty())
{
p = Path(_headerOutputDir, p.getBaseName());
}
p.setExtension("h");
std::string headerPath = p.toString();
std::string headerFileName = p.getFileName();
config().setString("outputFileName", implFileName);
config().setString("outputFilePath", implPath);
FileOutputStream implStream(implPath);
OutputLineEndingConverter implLEC(implStream);
writeFileHeader(implLEC);
pCodeWriter->writeImpl(implLEC, _headerPrefix + headerFileName);
config().setString("outputFileName", headerFileName);
config().setString("outputFilePath", headerPath);
FileOutputStream headerStream(headerPath);
OutputLineEndingConverter headerLEC(headerStream);
writeFileHeader(headerLEC);
pCodeWriter->writeHeader(headerLEC, headerFileName);
}
示例2: write
void write(const std::string& path, const Page& page, const std::string& clazz)
{
Path p(path);
config().setString("inputFileName", p.getFileName());
config().setString("inputFilePath", p.toString());
DateTime now;
config().setString("dateTime", DateTimeFormatter::format(now, DateTimeFormat::SORTABLE_FORMAT));
if (page.has("page.class"))
{
p.setBaseName(clazz);
}
std::unique_ptr<CodeWriter> pCodeWriter(createCodeWriter(page, clazz));
if (!_outputDir.empty())
{
p = Path(_outputDir, p.getBaseName());
}
if (!_base.empty())
{
p.setBaseName(_base);
}
p.setExtension("cpp");
std::string implPath = p.toString();
std::string implFileName = p.getFileName();
if (!_headerOutputDir.empty())
{
p = Path(_headerOutputDir, p.getBaseName());
}
p.setExtension("h");
std::string headerPath = p.toString();
std::string headerFileName = p.getFileName();
config().setString("outputFileName", implFileName);
config().setString("outputFilePath", implPath);
FileOutputStream implStream(implPath);
OutputLineEndingConverter implLEC(implStream);
writeFileHeader(implLEC);
pCodeWriter->writeImpl(implLEC, _headerPrefix + headerFileName);
config().setString("outputFileName", headerFileName);
config().setString("outputFilePath", headerPath);
FileOutputStream headerStream(headerPath);
OutputLineEndingConverter headerLEC(headerStream);
writeFileHeader(headerLEC);
pCodeWriter->writeHeader(headerLEC, headerFileName);
}
示例3: testDirectory
void FileTest::testDirectory()
{
File d("testdir");
try
{
d.remove(true);
}
catch (...)
{
}
TemporaryFile::registerForDeletion("testdir");
bool created = d.createDirectory();
assert (created);
assert (d.isDirectory());
assert (!d.isFile());
std::vector<std::string> files;
d.list(files);
assert (files.empty());
File f = Path("testdir/file1", Path::PATH_UNIX);
f.createFile();
f = Path("testdir/file2", Path::PATH_UNIX);
f.createFile();
f = Path("testdir/file3", Path::PATH_UNIX);
f.createFile();
d.list(files);
assert (files.size() == 3);
std::set<std::string> fs;
fs.insert(files.begin(), files.end());
assert (fs.find("file1") != fs.end());
assert (fs.find("file2") != fs.end());
assert (fs.find("file3") != fs.end());
File dd(Path("testdir/testdir2/testdir3", Path::PATH_UNIX));
dd.createDirectories();
assert (dd.exists());
assert (dd.isDirectory());
File ddd(Path("testdir/testdirB/testdirC/testdirD", Path::PATH_UNIX));
ddd.createDirectories();
assert (ddd.exists());
assert (ddd.isDirectory());
d.remove(true);
}
示例4: initialize
void AnthaxiaApp::initialize(Application& self) {
Settings::loadSettings("procsim.rc");
Poco::AutoPtr<AbstractConfiguration> pConfig;
if (Path("logging.cfg").isFile())
{
pConfig = new PropertyFileConfiguration("logging.cfg");
} else
{
pConfig = new MapConfiguration();
}
LoggingConfigurator configurator;
configurator.configure(pConfig);
Poco::LogStream log_stream(Poco::Logger::get("core.AnthaxiaApp"));
LOG_DEBUG("Logging initialized; continue initialization of the rest");
addSubsystem( new PluginManager() );
// Make sure the model control is instantiated
(void)ModelControl::getInstance();
// Make sure the service system is present
(void)ServiceSystem::getServiceSystem();
registerModelControlService();
Application::initialize(self);
}
示例5: copyResources
void copyResources()
{
logger().information("Copying resources");
Path path(config().getString("PocoDoc.output", "doc"));
if (config().hasProperty("PocoDoc.resources"))
{
std::string pages = config().getString("PocoDoc.resources");
StringTokenizer tokenizer(pages, ",\n", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
std::set<std::string> pageSet;
for (StringTokenizer::Iterator it = tokenizer.begin(); it != tokenizer.end(); ++it)
{
Glob::glob(*it, pageSet);
}
for (std::set<std::string>::const_iterator it = pageSet.begin(); it != pageSet.end(); ++it)
{
try
{
copyResource(Path(*it), path);
}
catch (Poco::Exception& exc)
{
logger().log(exc);
}
}
}
}
示例6: testStreamOpenerRelative
void URIStreamOpenerTest::testStreamOpenerRelative()
{
TemporaryFile tempFile;
std::string path = tempFile.path();
std::ofstream ostr(path.c_str());
assert (ostr.good());
ostr << "Hello, world!" << std::endl;
ostr.close();
URI uri(Path(path).toString(Path::PATH_UNIX));
std::string uriString = uri.toString();
URIStreamOpener opener;
std::istream* istr = opener.open(uri);
assert (istr != 0);
assert (istr->good());
delete istr;
}
示例7: findBundle
std::string BundleStreamFactoryTest::findBundle(const std::string& name)
{
std::string bundles("bundles");
std::string cwd(Path::current());
Path cwdPath(cwd);
Path p(cwdPath, bundles);
bool found = false;
while (!found && p.depth() > 0)
{
File f(p);
if (f.exists())
found = true;
else
p.popDirectory();
}
if (found)
return Path(p, name).toString();
else
throw Poco::FileNotFoundException(name);
}