本文整理汇总了C++中IODevice::get_size方法的典型用法代码示例。如果您正苦于以下问题:C++ IODevice::get_size方法的具体用法?C++ IODevice::get_size怎么用?C++ IODevice::get_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IODevice
的用法示例。
在下文中一共展示了IODevice::get_size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buffer
XMLTokenizer::XMLTokenizer(IODevice &input) : impl(new XMLTokenizer_Impl)
{
impl->input = input;
impl->size = input.get_size();
impl->pos = 0;
DataBuffer buffer(impl->size);
input.receive(buffer.get_data(), buffer.get_size(), true);
StringHelp::BOMType bom_type = StringHelp::detect_bom(buffer.get_data(), buffer.get_size());
switch (bom_type)
{
default:
case StringHelp::bom_none:
impl->data = StringHelp::utf8_to_text(std::string(buffer.get_data(), buffer.get_size()));
break;
case StringHelp::bom_utf32_be:
case StringHelp::bom_utf32_le:
throw Exception("UTF-16 XML files not supported yet");
break;
case StringHelp::bom_utf16_be:
case StringHelp::bom_utf16_le:
throw Exception("UTF-32 XML files not supported yet");
break;
case StringHelp::bom_utf8:
impl->data = StringHelp::utf8_to_text(std::string(buffer.get_data()+3, buffer.get_size()-3));
break;
}
}
示例2: font_face_load
void FontFamily_Impl::font_face_load(const FontDescription &desc, const std::string &typeface_name, float pixel_ratio)
{
#if defined(WIN32)
std::shared_ptr<FontEngine> engine = std::make_shared<FontEngine_Win32>(desc, typeface_name, pixel_ratio);
font_cache.push_back(Font_Cache(engine));
font_cache.back().glyph_cache->set_texture_group(texture_group);
font_cache.back().pixel_ratio = pixel_ratio;
#elif defined(__APPLE__)
std::shared_ptr<FontEngine> engine = std::make_shared<FontEngine_Cocoa>(desc, typeface_name, pixel_ratio);
font_cache.push_back(Font_Cache(engine));
font_cache.back().glyph_cache->set_texture_group(texture_group);
font_cache.back().pixel_ratio = pixel_ratio;
#elif defined(__ANDROID__)
throw Exception("automatic typeface to ttf file selection is not supported on android");
#else
// Obtain the best matching font file from fontconfig.
FontConfig &fc = FontConfig::instance();
std::string font_file_path = fc.match_font(typeface_name, desc);
std::string path = PathHelp::get_fullpath(font_file_path, PathHelp::path_type_file);
auto filename = PathHelp::get_filename(font_file_path, PathHelp::path_type_file);
auto fs = FileSystem(path);
IODevice file = fs.open_file(filename);
DataBuffer font_databuffer;
font_databuffer.set_size(file.get_size());
file.read(font_databuffer.get_data(), font_databuffer.get_size());
font_face_load(desc, font_databuffer, pixel_ratio);
#endif
}
示例3: load
void SoundProvider_Vorbis_Impl::load(IODevice &input)
{
int size = input.get_size();
buffer = DataBuffer(size);
int bytes_read = input.read(buffer.get_data(), buffer.get_size());
buffer.set_size(bytes_read);
}
示例4: load
ShaderObject ShaderObject::load(GraphicContext &gc, ShaderType shader_type, IODevice &file)
{
int size = file.get_size();
std::string source(size, 0);
file.read(&source[0], size);
return ShaderObject(gc, shader_type, StringHelp::local8_to_text(source));
}
示例5: add_sheet
void CSSDocument::add_sheet(CSSSheetOrigin origin, const std::string &filename, const FileSystem &fs)
{
// Load the css document:
IODevice file = fs.open_file(filename);
DataBuffer file_data(file.get_size());
file.read(file_data.get_data(), file_data.get_size());
std::string css_text(file_data.get_data(), file_data.get_size());
// Find the base URI for this css document:
std::string base_uri = PathHelp::get_fullpath(filename);
// Find import directives and load those first:
std::vector<std::string> import_urls = CSSTokenizer(css_text).read_import_urls();
for (size_t i = 0; i < import_urls.size(); i++)
{
add_sheet(origin, PathHelp::combine(base_uri, import_urls[i]), fs);
}
// Add the css sheet:
CSSTokenizer tokenizer(css_text);
impl->sheets.push_back(std::shared_ptr<CSSDocumentSheet>(new CSSDocumentSheet(origin, tokenizer, base_uri)));
}