本文整理汇总了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;
}