本文整理匯總了C++中string_t::has_chars方法的典型用法代碼示例。如果您正苦於以下問題:C++ string_t::has_chars方法的具體用法?C++ string_t::has_chars怎麽用?C++ string_t::has_chars使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類string_t
的用法示例。
在下文中一共展示了string_t::has_chars方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: defined
virtual bool open_file
(io::read::file& file, const string_t& line,
const string_t& name, bool mode_is_binary = false) {
size_t length;
if ((line.has_chars(length))) {
#if defined(__GNUC__)
char_t chars[length + 3];
#else // defined(__GNUC__)
nadir::arrayt<char_t> a(length + 3);
char_t* chars = a.elements();
#endif // defined(__GNUC__)
if ((file.open(name.chars(), (mode_is_binary)
?(file.mode_read_binary()):(file.mode_read())))) {
if (!((length + 2) != (file.read(chars, length + 2)))) {
if (!(line.compare(chars, length))) {
if (!((cr_ != chars[length]) || (lf_ != chars[length+1]))) {
return true;
}
}
}
file.close();
}
}
return false;
}
示例2:
virtual bool write_http
(talas::protocol::tls::connection& connection, const string_t& message) {
bool success = false;
size_t length = 0;
const char* chars = 0;
if ((chars = message.has_chars(length))) {
ssize_t count = 0;
TALAS_LOG_DEBUG("connection.write(chars = \"" << chars << "\", length = " << length << ")...");
if (length == (count = connection.write(chars, length))) {
TALAS_LOG_DEBUG("..." << count << " = connection.write(chars = \"" << chars << "\", length = " << length << ")");
return true;
} else {
TALAS_LOG_ERROR("...failed " << count << " = connection.write(chars = \"" << chars << "\", length = " << length << ")");
}
}
return success;
}