本文整理汇总了C++中IODevice类的典型用法代码示例。如果您正苦于以下问题:C++ IODevice类的具体用法?C++ IODevice怎么用?C++ IODevice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IODevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
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
}
示例2: impl
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;
}
}
示例3: readCommand
Error Commander::
readCommand(Command &cmd) {
Error rc;
IODevice *dd = d->device;
assert(dd != 0);
CommandHeader hdr;
char *buf = 0;
// Read header
{
size_t read_size;
rc = dd->read((char *)&hdr,sizeof(hdr), &read_size);
if (!rc.isSuccess()) {
return rc;
}
if( read_size != sizeof(hdr)) {
rc.setErrorType(Error::ERR_INVALID, "header corrupted");
return rc;
}
}
// Read command
{
buf = (char *)::malloc(hdr.length);
int tried_times = 0;
size_t offset = 0;
size_t read_size;
do {
rc = dd->read( (char *)(buf + offset), hdr.length-offset, &read_size);
if (!rc.isSuccess()) {
goto out;
}
offset += read_size;
}while(tried_times++ < 20 && offset < hdr.length);
}
{
String name;
std::vector<String> args;
size_t offset = 0;
name = buf;
offset += ::strlen(buf)+1;
while( (unsigned int)offset < (unsigned )hdr.length) {
args.push_back(buf+offset);
offset += ::strlen(buf+offset)+1;
}
cmd.setName(name);
cmd.setArguments(args);
}
if (buf) ::free(buf);
return rc;
out:
if (buf) ::free(buf);
return rc;
}
示例4:
void Zip64EndOfCentralDirectoryLocator::save(IODevice &output)
{
output.write_int32(signature);
output.write_int32(number_of_disk_with_zip64_end_of_central_directory);
output.write_int64(relative_offset_of_zip64_end_of_central_directory);
output.write_int32(total_number_of_disks);
}
示例5: 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);
}
示例6: 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));
}
示例7: setBackgroundImage
void LocalDeviceManager::setBackgroundImage(string uri) {
IODevice* dev;
map<unsigned int, IODevice*>::iterator i;
i = devices->find(0);
if (i != devices->end()) {
dev = i->second;
dev->setBackgroundImage(uri);
}
}
示例8: getGfxRoot
void* LocalDeviceManager::getGfxRoot(unsigned int deviceNumber) {
IODevice* dev;
if (devices->count(deviceNumber) == 0) {
return 0;
}
dev = (*devices)[deviceNumber];
return dev->getGfxRoot();
}
示例9: IOPending
void IOBuffer::attach(IODevice& ioDevice)
{
if( ioDevice.isReading() || ioDevice.isWriting() )
throw IOPending("IODevice in use");
this->detach();
_ioDevice = &ioDevice;
ioDevice.inputReady() += slot(*this, &IOBuffer::onRead);
ioDevice.outputReady() += slot(*this, &IOBuffer::onWrite);
}
示例10: releaseWindow
void LocalDeviceManager::releaseWindow(
void* win, unsigned int deviceNumber, unsigned int screenNumber) {
IODevice* dev;
if (devices->count(deviceNumber) == 0) {
return;
}
dev = (*devices)[deviceNumber];
return dev->releaseWindow(win, screenNumber);
}
示例11: Exception
void Zip64EndOfCentralDirectoryLocator::load(IODevice &input)
{
signature = input.read_int32();
if (signature != 0x07064b50)
{
throw Exception("Incorrect Zip64 End of central directory locator signature!");
}
number_of_disk_with_zip64_end_of_central_directory = input.read_int32();
relative_offset_of_zip64_end_of_central_directory = input.read_int64();
total_number_of_disks = input.read_int32();
}
示例12: getDeviceHeight
int LocalDeviceManager::getDeviceHeight(
unsigned int deviceNumber, unsigned int screenNumber) {
IODevice* dev;
if (devices->count(deviceNumber) == 0) {
return 0;
}
dev = (*devices)[deviceNumber];
return dev->getScreenHeightRes(screenNumber);
}
示例13: createSurface
void* LocalDeviceManager::createSurface(
void* surfaceDesc,
unsigned int deviceNumber, unsigned int screenNumber) {
IODevice* dev;
if (devices->count(deviceNumber) == 0) {
return NULL;
}
dev = (*devices)[deviceNumber];
return dev->createSurface(surfaceDesc, screenNumber);
}
示例14: releaseSurface
void LocalDeviceManager::releaseSurface(
void* sur,
unsigned int deviceNumber, unsigned int screenNumber) {
IODevice* dev;
if (devices->count(deviceNumber) == 0) {
return;
}
dev = (*devices)[deviceNumber];
return dev->releaseSurface(sur, screenNumber);
}
示例15: load
void OutlineProviderFile_Impl::load(IODevice &input_source)
{
// file type & version identifiers
int type = input_source.read_uint32();
unsigned char version = input_source.read_uint8();
if( type != 0x16082004 )
throw Exception("File is not a collision outline file" );
if( version != 1 )
throw Exception(string_format("Unsupported version of outline format: %1. Supported versions: 1.", version) );
// read in width and height
width = input_source.read_int32();
height = input_source.read_int32();
// x-pos of enclosing disc
minimum_enclosing_disc.position.x = input_source.read_float();
// y-pos of enclosing disc
minimum_enclosing_disc.position.y = input_source.read_float();
// radius of enclosing disc
minimum_enclosing_disc.radius = input_source.read_float();
// num contours
int num_contours = input_source.read_uint32();
for( int cc=0; cc < num_contours; ++cc )
{
Contour contour;
int num_points = input_source.read_uint32();
for( int pp=0; pp < num_points; ++pp )
{
Pointf point(0,0);
point.x = input_source.read_float();
point.y = input_source.read_float();
contour.get_points().push_back(point);
}
contours.push_back(contour);
}
}