本文整理汇总了C++中path::generic_string方法的典型用法代码示例。如果您正苦于以下问题:C++ path::generic_string方法的具体用法?C++ path::generic_string怎么用?C++ path::generic_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类path
的用法示例。
在下文中一共展示了path::generic_string方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resolve
path Attributes::resolve(path name)
{
Attribute *a = _search_attr(attrs, name.generic_string());
if (a && a->link().size() == 0)
return name;
path partial;
for(auto it=name.begin();it!=name.end();++it) {
partial /= *it;
a = _search_attr(attrs, partial.generic_string());
if (a) {
if (a->link().size()) {
path rest(a->link());
++it;
//everything matched - this is a link!
if (it == name.end())
return a->link();
for(;it!=name.end();++it)
rest /= *it;
return resolve(rest);
}
else //name is no valid path!
return name;
}
}
return name;
}
示例2:
Mp3Lib::Episode::Episode(path p)
{
#ifndef SILENT_EPISODE_CORE
cout << " Episode::Episode(" << p << ")" << endl;
#endif
_path = p;
_hash = sha256(p.generic_string());
_pMp3File = NULL;
#ifndef SILENT_EPISODE_CORE
cout << " Episode::init(void)" << endl;
#endif
vector<path> mp3s = FileBrowser::getFiles(_path, MP3);
#ifndef SILENT_EPISODE_INFO
cout << " Episode " << _hash << " (" << _path << ") is parsing mp3s" << endl;
#endif
for(vector<path>::iterator it = mp3s.begin(); it!=mp3s.end(); ++it)
{
#ifndef SILENT_EPISODE_INFO
cout << " Mp3 " << *it << endl;
#endif
_mp3Files.push_back(*it);
}
_mp3FilesIterator = _mp3Files.begin();
#ifndef SILENT_SERIES_INFO
cout << " Episode " << _path << " parsing mp3s done" << endl;
#endif
//FileBrowser::browseFolders(_path, this, COVER);
//FileBrowser::browseFolders(_path, this, MP3);
}
示例3: LoadFixedSizeFont
TTFFontPtr LoadFixedSizeFont(const path &path, int pointSize)const
{
const std::string pathUtf8 = ConvertPathToUtf8(GetResourceAbspath(path));
TTFFontPtr pFont(TTF_OpenFont(pathUtf8.c_str(), pointSize));
if (!pFont)
{
throw std::runtime_error("Cannot find font at " + path.generic_string());
}
return pFont;
}
示例4: LoadFileImage
SDLSurfacePtr LoadFileImage(const path &path)const
{
const std::string pathUtf8 = ConvertPathToUtf8(GetResourceAbspath(path));
SDLSurfacePtr pSurface(IMG_Load(pathUtf8.c_str()));
if (!pSurface)
{
throw std::runtime_error("Cannot find texture at " + path.generic_string());
}
return pSurface;
}
示例5: addLink
void Attributes::addLink(path name, path to)
{
Attribute a(resolve(name));
to = resolve(to);
if (a.name == to)
return;
a.setLink(to.generic_string());
append(a);
}
示例6: Save
void HTMLEditor::Save(const path & path)
{
if (path.empty())
{
throw runtime_error("Path cannot be empty!");
}
if (path.has_parent_path())
{
create_directories(path.parent_path());
}
std::ofstream file(path.generic_string());
if (!file.is_open())
{
throw runtime_error("Invalid path specified" + path.generic_string());
}
file << "<!DOCTYPE html>\n<html>\n<head>\n\t<title>" << EncodeHtmlStr(m_document.GetTitle()) << "</title>\n</head>\n"
<< "<body>\n" << CreateBody(path) << "</body>\n</html>";
file.close();
}
示例7: save
virtual void save( const path& db ) override
{
std::ofstream out( db.generic_string(),
std::ofstream::binary | std::ofstream::out | std::ofstream::trunc );
FC_ASSERT( out );
auto ver = get_object_version();
fc::raw::pack( out, _next_id );
fc::raw::pack( out, ver );
this->inspect_all_objects( [&]( const object& o ) {
auto vec = fc::raw::pack( static_cast<const object_type&>(o) );
auto packed_vec = fc::raw::pack( vec );
out.write( packed_vec.data(), packed_vec.size() );
});
}
示例8: GetResourceAbspath
path GetResourceAbspath(const path &relpath)const
{
if (relpath.is_absolute())
{
return relpath;
}
for (const auto &dir : m_searchPaths)
{
const path abspath = absolute(relpath, dir);
if (exists(abspath))
{
return abspath;
}
}
throw std::runtime_error("Resource not found: " + relpath.generic_string());
}
示例9: open
virtual void open( const path& db )override
{
if( !fc::exists( db ) ) return;
fc::file_mapping fm( db.generic_string().c_str(), fc::read_only );
fc::mapped_region mr( fm, fc::read_only, 0, fc::file_size(db) );
fc::datastream<const char*> ds( (const char*)mr.get_address(), mr.get_size() );
fc::sha256 open_ver;
fc::raw::unpack(ds, _next_id);
fc::raw::unpack(ds, open_ver);
FC_ASSERT( open_ver == get_object_version(), "Incompatible Version, the serialization of objects in this index has changed" );
try {
vector<char> tmp;
while( true )
{
fc::raw::unpack( ds, tmp );
load( tmp );
}
} catch ( const fc::exception& ){}
}
示例10: LoadFileAsString
std::string LoadFileAsString(const path &relpath)
{
const path abspath = GetResourceAbspath(relpath);
std::ifstream input;
input.open(abspath.native());
if (!input.is_open())
{
throw std::runtime_error("Cannot open for reading: " + abspath.generic_string());
}
std::string text;
text.reserve(FILE_RESERVE_SIZE);
input.exceptions(std::ios::badbit);
std::string line;
while (std::getline(input, line))
{
text.append(line);
text.append("\n");
}
return text;
}
示例11: hash_value
size_t hash_value(const path& p) noexcept
{
return std::hash<path::string_type>()(p.generic_string());
}
示例12: toString
/** path to UTF-8 encoding. */
std::string toString(const path& p)
{
return p.generic_string();
}