本文整理汇总了C++中CL_StringRef::data方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_StringRef::data方法的具体用法?C++ CL_StringRef::data怎么用?C++ CL_StringRef::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_StringRef
的用法示例。
在下文中一共展示了CL_StringRef::data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unescape
inline void CL_XMLTokenizer_Generic::unescape(CL_StringRef &text, const CL_StringRef &search, CL_String::char_type replace)
{
CL_StringRef::size_type read_pos = 0;
CL_StringRef::size_type length = text.length();
CL_StringRef::size_type search_length = search.length();
CL_StringRef::char_type *data = text.data();
while (true)
{
CL_StringRef::size_type next_match = text.find(search, read_pos);
if (next_match == CL_StringRef::npos)
break;
CL_StringRef::size_type copy_size = length - (next_match + search_length);
memcpy(data + next_match + 1, data + next_match + search_length, copy_size * sizeof(CL_StringRef::char_type));
data[next_match] = replace;
length -= search_length - 1;
read_pos = next_match + 1;
if (read_pos > length)
break;
}
text.set_length(length);
}
示例2: write
void CL_Console::write(const CL_StringRef &text)
{
#ifdef WIN32
/*
Do not replace WriteConsole with the commented WriteFile code unless you
really know what you are doing and understand when ANSI code pages are used and
when OEM code pages are used. -- mbn 29. jan 2008
CL_String8 t = CL_StringHelp::text_to_local8(text);
DWORD written = 0;
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), t.data(), t.length(), &written, 0);
*/
DWORD written = 0;
CL_String16 str = CL_StringHelp::utf8_to_ucs2(text);
WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), str.c_str(), str.length(), &written, 0);
#else
::write(1, text.data(), text.length());
#endif
}