本文整理汇总了C++中StringView::to_string方法的典型用法代码示例。如果您正苦于以下问题:C++ StringView::to_string方法的具体用法?C++ StringView::to_string怎么用?C++ StringView::to_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringView
的用法示例。
在下文中一共展示了StringView::to_string方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromTextReader
bool CSVData::loadFromTextReader(TextReader& reader, const StringView separators, const StringView quotes, const StringView escapes)
{
if (!reader)
{
return false;
}
const boost::escaped_list_separator<char32> separator(escapes.to_string(), separators.to_string(), quotes.to_string());
String str;
m_data.clear();
while (reader.readLine(str))
{
try
{
const boost::tokenizer<boost::escaped_list_separator<char32>, String::const_iterator, String> tokens(str, separator);
m_data.emplace_back(tokens.begin(), tokens.end());
}
catch (boost::exception&)
{
str.replace(U"\\", U"\\\\");
const boost::tokenizer<boost::escaped_list_separator<char32>, String::const_iterator, String> tokens(str, separator);
m_data.emplace_back(tokens.begin(), tokens.end());
}
}
return true;
}
示例2: SplitBam
void SplitBam(const BamRecord& record
, BamRecord& outbam
, const StringView& run_name
, const StringView& zmw
, int left_start
, int right_end
, const StripedSmithWaterman::Alignment& alignment
) {
// name
stringstream name;
name << run_name.to_string() << '/' << zmw << '/';
if (is_left) {
name << left_start << '_' << (left_start + alignment.ref_begin);
} else {
name << (left_start + alignment.ref_end + 1) << '_' << right_end;
}
outbam.Impl().Name(name.str());
// sequence
outbam.Impl().SetSequenceAndQualities(
is_left ?
record.Sequence().substr(0, alignment.ref_begin) :
record.Sequence().substr(alignment.ref_end + 1)
, ""
);
// tags
const auto& original_tags = record.Impl().Tags();
TagCollection newtags;
// direct copy tags
for (auto t : {"RG", "np", "rq", "sn", "zm"}) {
newtags[t] = original_tags.at(t);
}
// tags need to substr
for (auto t : {"dq", "dt", "iq", "mq", "sq"}) {
if (is_left)
newtags[t] = original_tags.at(t).ToString().substr(0, alignment.ref_begin);
else
newtags[t] = original_tags.at(t).ToString().substr(alignment.ref_end + 1);
}
// special tag
newtags["qs"] = (is_left ? left_start : left_start + alignment.ref_end + 1);
newtags["qe"] = (is_left ? left_start + alignment.ref_begin : right_end);
newtags["cx"] = original_tags.at("cx").ToUInt8()
| (is_left ? PacBio::BAM::LocalContextFlags::ADAPTER_BEFORE : PacBio::BAM::LocalContextFlags::ADAPTER_AFTER);
// TODO: this can be more efficient
auto vec = record.IPD().Encode();
if (is_left) {
newtags["ip"] = decltype(vec){vec.cbegin(), vec.cbegin() + alignment.ref_begin};
} else {
newtags["ip"] = decltype(vec){vec.cbegin() + alignment.ref_end + 1, vec.cend()};
}
outbam.Impl().Tags(newtags);
}
示例3: getColumnIndex
/*
* Also does implicit conversions form std::string and const char*
*/
std::size_t getColumnIndex(StringView columnName)
{
auto& columnNameMappings = getColumnNameMappingsRef();
using std::begin;
using std::end;
auto it = std::lower_bound(begin(columnNameMappings), end(columnNameMappings), columnName, [](auto&& elem, auto&& value) {
return std::get<0>(elem) < value;
});
if (it != end(columnNameMappings) && !(columnName < std::get<0>(*it)))
{
return std::get<1>(*it);
}
else
{
throw OutOfRange{"Column name \"" + columnName.to_string() + "\" not found!"};
}
}
示例4: StringViewTo
bool StringViewTo(const StringView& s, T& t) {
std::istringstream ss(s.to_string());
ss >> t;
return ss.fail() ? false : true;
}