本文整理汇总了C++中tstring::str方法的典型用法代码示例。如果您正苦于以下问题:C++ tstring::str方法的具体用法?C++ tstring::str怎么用?C++ tstring::str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tstring
的用法示例。
在下文中一共展示了tstring::str方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: search_executable
std::string search_executable(tstring const& filename, tstring const& path)
{
const bool filename_has_extension = has_extension(filename);
const bool filename_is_absolute_path = is_absolute(filename);
const std::vector<std::string> extensions = get_executable_extensions();
if( ! filename_is_absolute_path ) {
const std::vector<std::string> dirs = split(path, PATH_SEPARATOR);
for(std::vector<std::string>::const_iterator ipath = dirs.begin(); ipath != dirs.end(); ++ipath ) {
const std::string path1 = tinfra::path::join(*ipath, filename);
if( filename_has_extension ) {
if( is_executable(path1 ,extensions) )
return path1;
continue;
}
std::string maybe_with_ext = find_variant(path1, extensions);
if( ! maybe_with_ext.empty() )
return maybe_with_ext;
}
} else if( ! filename_has_extension ) {
return find_variant(filename.str(), extensions);
} else {
if( is_executable(filename, extensions) ) {
return filename.str();
}
}
return "";
}
示例2: basename
std::string basename(tstring const& name)
{
std::string::size_type p = name.find_last_of("/\\");
if( p == tstring::npos ) {
return name.str();
} else {
return std::string(name.data()+p+1, name.size()-p-1);
}
}
示例3: start_detached
void start_detached(tstring const& command, environment_t const* env)
{
std::auto_ptr<subprocess> p = subprocess::create();
p->set_stdout_mode(subprocess::NONE);
p->set_stdin_mode(subprocess::NONE);
p->set_stderr_mode(subprocess::NONE);
if( env )
p->set_environment(*env);
p->start(command.str().c_str());
p->detach();
}
示例4: remove_all_extensions
std::string remove_all_extensions(tstring const& filename)
{
const size_t last_slash = filename.find_last_of("\\/");
const size_t last_dot = filename.find_first_of('.', last_slash);
if( ( last_dot == tstring::npos ) ||
( last_dot == filename.size() - 1 ) )
{
return filename.str();
} else {
tstring result = filename.substr(0, last_dot);
return result.str();
}
}
示例5: logic_error
test_fs_sandbox::test_fs_sandbox(tstring const& name):
fs_sandbox(tinfra::local_fs()),
name_(name.str())
{
if( name_.size() > 0 ) {
string real_path = path::join(top_srcdir, name_);
if( !fs::exists(real_path) ) {
const std::string error_message = (fmt("unable to find test resource %s (%s)") % name_ % real_path).str();
throw std::logic_error(error_message);
}
fs::recursive_copy(real_path, fs_sandbox::path());
}
orig_pwd_ = fs::pwd();
fs::cd(fs_sandbox::path());
TINFRA_TRACE(test_fs_sandbox_tracer, fmt("entering sandbox pwd='%s'") % fs_sandbox::path());
}
示例6: get_id_for_name
id_type get_id_for_name(tstring const& name)
{
tinfra::guard instance_guard(instance_lock_);
name_to_id_mapping_t::const_iterator i = name_map_.find(name);
if( i == name_map_.end() )
{
id_type result_id = next_symbol_id_++;
name_storage_t::const_iterator istr = name_storage_.insert(name_storage_.end(), name.str());
tstring name_allocated(*istr);
name_index_.push_back(istr);
name_map_[name_allocated] = result_id;
return result_id;
}
else
{
return i->second;
}
}
示例7: foo
static void foo(tstring const& a)
{
std::string x = a.str();
}