本文整理汇总了C++中CL_StringRef::length方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_StringRef::length方法的具体用法?C++ CL_StringRef::length怎么用?C++ CL_StringRef::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_StringRef
的用法示例。
在下文中一共展示了CL_StringRef::length方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insert_glyph
void CL_GlyphCache::insert_glyph(CL_FontEngine *font_engine, CL_GraphicContext &gc, const CL_StringRef &text)
{
for (CL_String::size_type p = 0; p < text.length(); ++p)
{
insert_glyph(font_engine, gc, text[p]);
}
}
示例2: begin_file
void CL_ZipWriter::begin_file(const CL_StringRef &filename, bool compress)
{
if (impl->file_begun)
throw CL_Exception("CL_ZipWriter already writing a file");
impl->file_begun = true;
impl->uncompressed_length = 0;
impl->compressed_length = 0;
impl->compress = compress;
impl->crc32 = CL_ZIP_CRC_START_VALUE;
impl->local_header_offset = impl->output.get_position();
impl->local_header = CL_ZipLocalFileHeader();
impl->local_header.version_needed_to_extract = 20;
if (impl->storeFilenamesAsUTF8)
impl->local_header.general_purpose_bit_flag = CL_ZIP_USE_UTF8;
else
impl->local_header.general_purpose_bit_flag = 0;
impl->local_header.compression_method = compress ? zip_compress_deflate : zip_compress_store;
CL_ZipArchive_Impl::calc_time_and_date(
impl->local_header.last_mod_file_date,
impl->local_header.last_mod_file_time);
impl->local_header.crc32 = 0;
impl->local_header.uncompressed_size = 0;
impl->local_header.compressed_size = 0;
impl->local_header.file_name_length = filename.length();
impl->local_header.filename = filename;
if (!impl->storeFilenamesAsUTF8) // Add UTF-8 as extra field if we aren't storing normal UTF-8 filenames
{
// -Info-ZIP Unicode Path Extra Field (0x7075)
CL_String8 filename_cp437 = CL_StringHelp::text_to_cp437(filename);
CL_String8 filename_utf8 = CL_StringHelp::text_to_utf8(filename);
CL_DataBuffer unicode_path(9 + filename_utf8.length());
cl_ubyte16 *extra_id = (cl_ubyte16 *) (unicode_path.get_data());
cl_ubyte16 *extra_len = (cl_ubyte16 *) (unicode_path.get_data() + 2);
cl_ubyte8 *extra_version = (cl_ubyte8 *) (unicode_path.get_data() + 4);
cl_ubyte32 *extra_crc32 = (cl_ubyte32 *) (unicode_path.get_data() + 5);
*extra_id = 0x7075;
*extra_len = 5 + filename_utf8.length();
*extra_version = 1;
*extra_crc32 = CL_ZipArchive_Impl::calc_crc32(filename_cp437.data(), filename_cp437.size());
memcpy(unicode_path.get_data() + 9, filename_utf8.data(), filename_utf8.length());
impl->local_header.extra_field_length = unicode_path.get_size();
impl->local_header.extra_field = unicode_path;
}
impl->local_header.save(impl->output);
if (compress)
{
memset(&impl->zs, 0, sizeof(z_stream));
int result = deflateInit2(&impl->zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY); // Undocumented: if wbits is negative, zlib skips header check
if (result != Z_OK)
throw CL_Exception("Zlib deflateInit failed for zip index!");
}
}
示例3: set_arg
void CL_StringFormat::set_arg(int index, const CL_StringRef &text)
{
if (index >= (int) args.size())
return;
ArgPosition pos = args[index];
if (pos.length == 0)
return;
int delta_size = ((int) text.length()) - pos.length;
string = string.substr(0, pos.start) + text + string.substr(pos.start + pos.length);
args[index].length = text.length();
std::vector<ArgPosition>::size_type i, size;
size = args.size();
for (i = 0; i < size; i++)
{
if (args[i].start > pos.start)
args[i].start += delta_size;
}
}
示例4: 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);
}
示例5: style_load_until
unsigned int CL_CSSDocument_Impl::style_load_until(const CL_StringRef::char_type *chars, const CL_StringRef &style_text, unsigned int pos)
{
bool quotes1 = false;
bool quotes2 = false;
int level = 0;
while (pos < style_text.length())
{
if (level == 0 && quotes1 == false && quotes2 == false)
{
for (int i = 0; chars[i] != 0; i++)
{
if (style_text[pos] == chars[i])
return pos;
}
}
switch (style_text[pos++])
{
case '"':
quotes1 = !quotes1;
break;
case '\'':
quotes2 = !quotes2;
break;
case '(':
case '{':
case '[':
if (quotes1 || quotes2)
break;
level++;
break;
case ')':
case '}':
case ']':
if (quotes1 || quotes2)
break;
level--;
break;
case '\\':
pos++;
break;
}
}
return pos;
}
示例6: 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
}
示例7: draw_text
void CL_GlyphCache::draw_text(CL_FontEngine *font_engine, CL_GraphicContext &gc, float xpos, float ypos, const CL_StringRef &text, const CL_Colorf &color)
{
CL_String::size_type string_length = text.length();
if (string_length==0)
{
return;
}
CL_RenderBatcherSprite *batcher = gc.impl->current_internal_batcher;
// Scan the string
CL_UTF8_Reader reader(text);
while(!reader.is_end())
{
unsigned int glyph = reader.get_char();
reader.next();
CL_Font_TextureGlyph *gptr = get_glyph(font_engine, gc, glyph);
if (gptr == NULL) continue;
if (!gptr->empty_buffer)
{
float xp = xpos + gptr->offset.x;
float yp = ypos + gptr->offset.y;
CL_Rectf dest_size(xp, yp, CL_Sizef(gptr->geometry.get_size()));
if (enable_subpixel)
{
batcher->draw_glyph_subpixel(gc, gptr->geometry, dest_size, color, gptr->subtexture.get_texture());
}else
{
batcher->draw_image(gc, gptr->geometry, dest_size, color, gptr->subtexture.get_texture());
}
}
xpos += gptr->increment.x;
ypos += gptr->increment.y;
}
}
示例8: buffer
std::vector<CL_String> CL_RegistryKey::get_value_multi_string(const CL_StringRef &name, const std::vector<CL_String> &default_value) const
{
DWORD type = 0, size_data = 0;
LONG result = RegQueryValueEx(impl->key, CL_StringHelp::utf8_to_ucs2(name).c_str(), 0, &type, 0, &size_data);
if (result != ERROR_SUCCESS || type != REG_MULTI_SZ)
return default_value;
CL_DataBuffer buffer(size_data);
size_data = buffer.get_size();
result = RegQueryValueEx(impl->key, CL_StringHelp::utf8_to_ucs2(name).c_str(), 0, &type, (LPBYTE) buffer.get_data(), &size_data);
if (result != ERROR_SUCCESS || type != REG_MULTI_SZ)
return default_value;
std::vector<CL_String> results;
TCHAR *pos = (TCHAR *) buffer.get_data();
while (*pos != 0)
{
CL_StringRef s = pos;
results.push_back(s);
pos += s.length()+1;
}
return results;
}
示例9: set_value_string
void CL_RegistryKey::set_value_string(const CL_StringRef &name, const CL_StringRef &value)
{
LONG result = RegSetValueEx(impl->key, name.empty() ? 0 : CL_StringHelp::utf8_to_ucs2(name).c_str(), 0, REG_SZ, (const BYTE *) value.c_str(), (value.length()+1) * sizeof(TCHAR));
if (result != ERROR_SUCCESS)
throw CL_Exception(cl_format("Unable to set registry key value %1", name));
}
示例10: set_archive_filename
void CL_ZipFileEntry::set_archive_filename(const CL_StringRef &filename)
{
impl->record.file_name_length = filename.length();
impl->record.filename = filename;
}