本文整理汇总了C++中std::string::data方法的典型用法代码示例。如果您正苦于以下问题:C++ string::data方法的具体用法?C++ string::data怎么用?C++ string::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::string
的用法示例。
在下文中一共展示了string::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qstr
inline QString qstr(const std::string& _in) { return QString::fromUtf8(_in.data(), _in.size()); }
示例2: send
long Socket::send(const std::string &buf) const
{
return send_all(this->socket_handle, buf.data(), buf.length() );
}
示例3:
void HashFunctions::sha512(const std::string &data, unsigned char out_hash[64])
{
sha512(data.data(), data.length(), out_hash);
}
示例4: bind
int SqliteStatement::bind (int position, const std::string& value)
{
return sqlite3_bind_text (statement, position, value.data (), value.size (), SQLITE_TRANSIENT);
}
示例5: sendString
unsigned NetClient::sendString(const std::string &s) throw(const SocketException &)
{
return sendData(s.data(), s.length());
}
示例6: add_member
/**
* Add a member to the relation.
*
* @param type The type (node, way, or relation).
* @param ref The ID of the member.
* @param role The role of the member.
* @param full_member Optional pointer to the member object. If it
* is available a copy will be added to the
* relation.
* @throws std:length_error If role is longer than osmium::max_osm_string_length
*/
void add_member(osmium::item_type type, object_id_type ref, const std::string& role, const osmium::OSMObject* full_member = nullptr) {
add_member(type, ref, role.data(), role.size(), full_member);
}
示例7: FileWriteStr
static int FileWriteStr(const std::string &str, FILE *fp)
{
return fwrite(str.data(), 1, str.size(), fp);
}
示例8: Get
//.........这里部分代码省略.........
strHTML.assign(buffer.get(), buffer.length());
return true;
}
}
}
std::string strHTML1(strHTML);
if (scrURL.m_post)
{
std::string strOptions = url.GetOptions();
strOptions = strOptions.substr(1);
url.SetOptions("");
if (!http.Post(url.Get(), strOptions, strHTML1))
return false;
}
else
if (!http.Get(url.Get(), strHTML1))
return false;
strHTML = strHTML1;
std::string mimeType(http.GetMimeType());
CMime::EFileType ftype = CMime::GetFileTypeFromMime(mimeType);
if (ftype == CMime::FileTypeUnknown)
ftype = CMime::GetFileTypeFromContent(strHTML);
if (ftype == CMime::FileTypeZip || ftype == CMime::FileTypeGZip)
{
XFILE::CZipFile file;
std::string strBuffer;
int iSize = file.UnpackFromMemory(strBuffer,strHTML,scrURL.m_isgz); // FIXME: use FileTypeGZip instead of scrURL.m_isgz?
if (iSize > 0)
{
strHTML = strBuffer;
CLog::Log(LOGDEBUG, "%s: Archive \"%s\" was unpacked in memory", __FUNCTION__, scrURL.m_url.c_str());
}
else
CLog::Log(LOGWARNING, "%s: \"%s\" looks like archive, but cannot be unpacked", __FUNCTION__, scrURL.m_url.c_str());
}
std::string reportedCharset(http.GetServerReportedCharset());
if (ftype == CMime::FileTypeHtml)
{
std::string realHtmlCharset, converted;
if (!CCharsetDetection::ConvertHtmlToUtf8(strHTML, converted, reportedCharset, realHtmlCharset))
CLog::Log(LOGWARNING, "%s: Can't find precise charset for HTML \"%s\", using \"%s\" as fallback", __FUNCTION__, scrURL.m_url.c_str(), realHtmlCharset.c_str());
else
CLog::Log(LOGDEBUG, "%s: Using \"%s\" charset for HTML \"%s\"", __FUNCTION__, realHtmlCharset.c_str(), scrURL.m_url.c_str());
strHTML = converted;
}
else if (ftype == CMime::FileTypeXml)
{
CXBMCTinyXML xmlDoc;
xmlDoc.Parse(strHTML, reportedCharset);
std::string realXmlCharset(xmlDoc.GetUsedCharset());
if (!realXmlCharset.empty())
{
CLog::Log(LOGDEBUG, "%s: Using \"%s\" charset for XML \"%s\"", __FUNCTION__, realXmlCharset.c_str(), scrURL.m_url.c_str());
std::string converted;
g_charsetConverter.ToUtf8(realXmlCharset, strHTML, converted);
strHTML = converted;
}
}
else if (ftype == CMime::FileTypePlainText || StringUtils::CompareNoCase(mimeType.substr(0, 5), "text/") == 0)
{
std::string realTextCharset, converted;
CCharsetDetection::ConvertPlainTextToUtf8(strHTML, converted, reportedCharset, realTextCharset);
strHTML = converted;
if (reportedCharset != realTextCharset)
CLog::Log(LOGWARNING, "%s: Using \"%s\" charset for plain text \"%s\" instead of server reported \"%s\" charset", __FUNCTION__, realTextCharset.c_str(), scrURL.m_url.c_str(), reportedCharset.c_str());
else
CLog::Log(LOGDEBUG, "%s: Using \"%s\" charset for plain text \"%s\"", __FUNCTION__, realTextCharset.c_str(), scrURL.m_url.c_str());
}
else if (!reportedCharset.empty())
{
CLog::Log(LOGDEBUG, "%s: Using \"%s\" charset for \"%s\"", __FUNCTION__, reportedCharset.c_str(), scrURL.m_url.c_str());
if (reportedCharset != "UTF-8")
{
std::string converted;
g_charsetConverter.ToUtf8(reportedCharset, strHTML, converted);
strHTML = converted;
}
}
else
CLog::Log(LOGDEBUG, "%s: Using content of \"%s\" as binary or text with \"UTF-8\" charset", __FUNCTION__, scrURL.m_url.c_str());
if (!scrURL.m_cache.empty())
{
std::string strCachePath = URIUtils::AddFileToFolder(g_advancedSettings.m_cachePath,
"scrapers", cacheContext, scrURL.m_cache);
XFILE::CFile file;
if (!file.OpenForWrite(strCachePath, true) || file.Write(strHTML.data(), strHTML.size()) != static_cast<ssize_t>(strHTML.size()))
return false;
}
return true;
}
示例9: RealOutput
void CGI::RealOutput(const std::string &what)
{
RealOutput(what.data(), what.length());
}
示例10:
void operator & (const std::string &s)
{
size_t size = s.size();
*this & (size);
stream.write(s.data(), size);
}
示例11: OutputBody
void CGI::OutputBody(const std::string &body)
{
OutputBody(body.data(), body.length());
}
示例12: WriteString
void WriteString(ignite::impl::binary::BinaryWriterImpl& writer, const std::string & str)
{
writer.WriteString(str.data(), static_cast<int32_t>(str.size()));
}
示例13: atoi
Integer::Integer(std::string str) {
i = atoi(str.data());
}
示例14:
INT64 StringUtility::StringToInt64( std::string str )
{
INT64 i;
i = _atoi64(str.data());
return i;
}
示例15: load
void StreamBuffer::load(const std::string &str){
clear();
put(str.data(), str.size());
}