本文整理汇总了C++中string_type::data方法的典型用法代码示例。如果您正苦于以下问题:C++ string_type::data方法的具体用法?C++ string_type::data怎么用?C++ string_type::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string_type
的用法示例。
在下文中一共展示了string_type::data方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testbuf
testbuf(const string_type& str)
: str_(str)
{
base::setg(const_cast<CharT*>(str_.data()),
const_cast<CharT*>(str_.data()),
const_cast<CharT*>(str_.data()) + str_.size());
}
示例2: consume
void backend::consume(string_type const& formatted_message)
{
if (!impl_)
return;
if((impl_->file_.is_open() && (impl_->written_ + formatted_message.size() >= 512*1024) )
|| !impl_->file_.good()
)
{
rotate_file();
}
if (!impl_->file_.is_open())
{
fs::create_directories(impl_->root_);
impl_->file_.open((impl_->root_ / (impl_->name_ + L".log")).c_str(), std::ios_base::app | std::ios_base::out);
if (!impl_->file_.is_open())
{
throw bee::exception("Failed to open file '%s' for writing.", (impl_->root_ / (impl_->name_ + L".log")).string().c_str());
}
impl_->written_ = static_cast<std::streamoff>(impl_->file_.tellp());
}
impl_->file_.write(formatted_message.data(), static_cast<std::streamsize>(formatted_message.size()));
impl_->file_.put(static_cast<string_type::value_type>('\n'));
impl_->written_ += formatted_message.size() + 1;
impl_->file_.flush();
}
示例3: consume
//! The method writes the message to the sink
BOOST_LOG_API void text_multifile_backend::consume(record_view const& rec, string_type const& formatted_message)
{
if (!m_pImpl->m_FileNameComposer.empty())
{
filesystem::path file_name = m_pImpl->make_absolute(m_pImpl->m_FileNameComposer(rec));
filesystem::create_directories(file_name.parent_path());
m_pImpl->m_File.open(file_name, std::ios_base::out | std::ios_base::app);
if (m_pImpl->m_File.is_open())
{
m_pImpl->m_File.write(formatted_message.data(), static_cast< std::streamsize >(formatted_message.size()));
m_pImpl->m_File.put(static_cast< string_type::value_type >('\n'));
m_pImpl->m_File.close();
}
}
}
示例4:
BOOST_LOG_API void basic_text_ostream_backend< CharT >::consume(record_view const&, string_type const& message)
{
typename string_type::const_pointer const p = message.data();
typename string_type::size_type const s = message.size();
typename implementation::ostream_sequence::const_iterator
it = m_pImpl->m_Streams.begin(), end = m_pImpl->m_Streams.end();
for (; it != end; ++it)
{
register stream_type* const strm = it->get();
if (strm->good())
{
strm->write(p, static_cast< std::streamsize >(s));
strm->put(static_cast< char_type >('\n'));
if (m_pImpl->m_fAutoFlush)
strm->flush();
}
}
}
示例5: transform
///
/// Create a binary string from string \a s, that can be compared to other, useful for collation of multiple
/// strings.
///
/// The transformation follows these rules:
/// \code
/// compare(level,s1,s2) == sign( transform(level,s1).compare(transform(level,s2)) );
/// \endcode
///
string_type transform(level_type level,string_type const &s) const
{
return do_transform(level,s.data(),s.data()+s.size());
}
示例6: hash
long hash(level_type level,string_type const &s) const
{
return do_hash(level,s.data(),s.data()+s.size());
}
示例7: compare
///
/// Compare two strings \a l and \a r using collation level \a level
///
/// Returns -1 if the first of the two strings sorts before the seconds, returns 1 if sorts after and 0 if
/// they considered equal.
///
///
int compare(level_type level,string_type const &l,string_type const &r) const
{
return do_compare(level,l.data(),l.data()+l.size(),r.data(),r.data()+r.size());
}
示例8: find
/*!
* The method finds the attribute value by name.
*
* \param key Attribute name.
* \return Iterator to the found element or \c end() if the attribute with such name is not found.
*/
const_iterator find(string_type const& key) const
{
return find_impl(key.data(), key.size());
}