本文整理汇总了C++中xfile::auto_buffer::size方法的典型用法代码示例。如果您正苦于以下问题:C++ auto_buffer::size方法的具体用法?C++ auto_buffer::size怎么用?C++ auto_buffer::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xfile::auto_buffer
的用法示例。
在下文中一共展示了auto_buffer::size方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFile
bool CPODocument::LoadFile(const std::string &pofilename)
{
CURL poFileUrl(pofilename);
if (!XFILE::CFile::Exists(poFileUrl))
return false;
XFILE::CFile file;
XFILE::auto_buffer buf;
if (file.LoadFile(poFileUrl, buf) < 18) // at least a size of a minimalistic header
{
CLog::Log(LOGERROR, "%s: can't load file \"%s\" or file is too small", __FUNCTION__, pofilename.c_str());
return false;
}
m_strBuffer = '\n';
m_strBuffer.append(buf.get(), buf.size());
buf.clear();
ConvertLineEnds(pofilename);
// we make sure, to have an LF at the end of buffer
if (*m_strBuffer.rbegin() != '\n')
{
m_strBuffer += "\n";
}
m_POfilelength = m_strBuffer.size();
if (GetNextEntry() && m_Entry.Type == MSGID_FOUND)
return true;
CLog::Log(LOGERROR, "POParser: unable to read PO file header from file: %s", pofilename.c_str());
return false;
}
示例2: LoadFromFileInternal
bool CBaseTexture::LoadFromFileInternal(const std::string& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool autoRotate, bool requirePixels, const std::string& strMimeType)
{
if (URIUtils::HasExtension(texturePath, ".dds"))
{ // special case for DDS images
CDDSImage image;
if (image.ReadFile(texturePath))
{
Update(image.GetWidth(), image.GetHeight(), 0, image.GetFormat(), image.GetData(), false);
return true;
}
return false;
}
unsigned int width = maxWidth ? std::min(maxWidth, g_Windowing.GetMaxTextureSize()) : g_Windowing.GetMaxTextureSize();
unsigned int height = maxHeight ? std::min(maxHeight, g_Windowing.GetMaxTextureSize()) : g_Windowing.GetMaxTextureSize();
// Read image into memory to use our vfs
XFILE::CFile file;
XFILE::auto_buffer buf;
if (file.LoadFile(texturePath, buf) <= 0)
return false;
CURL url(texturePath);
// make sure resource:// paths are properly resolved
if (url.IsProtocol("resource"))
{
std::string translatedPath;
if (XFILE::CResourceFile::TranslatePath(url, translatedPath))
url.Parse(translatedPath);
}
// handle xbt:// paths differently because it allows loading the texture directly from memory
if (url.IsProtocol("xbt"))
{
XFILE::CXbtFile xbtFile;
if (!xbtFile.Open(url))
return false;
return LoadFromMemory(xbtFile.GetImageWidth(), xbtFile.GetImageHeight(), 0, xbtFile.GetImageFormat(),
xbtFile.HasImageAlpha(), reinterpret_cast<unsigned char*>(buf.get()));
}
IImage* pImage;
if(strMimeType.empty())
pImage = ImageFactory::CreateLoader(texturePath);
else
pImage = ImageFactory::CreateLoaderFromMimeType(strMimeType);
if (!LoadIImage(pImage, (unsigned char *)buf.get(), buf.size(), width, height, autoRotate))
{
CLog::Log(LOGDEBUG, "%s - Load of %s failed.", __FUNCTION__, texturePath.c_str());
delete pImage;
return false;
}
delete pImage;
return true;
}
示例3: LoadFromFileInternal
bool CBaseTexture::LoadFromFileInternal(const std::string& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool autoRotate, bool requirePixels, const std::string& strMimeType)
{
if (URIUtils::HasExtension(texturePath, ".dds"))
{ // special case for DDS images
CDDSImage image;
if (image.ReadFile(texturePath))
{
Update(image.GetWidth(), image.GetHeight(), 0, image.GetFormat(), image.GetData(), false);
return true;
}
return false;
}
unsigned int width = maxWidth ? std::min(maxWidth, g_Windowing.GetMaxTextureSize()) : g_Windowing.GetMaxTextureSize();
unsigned int height = maxHeight ? std::min(maxHeight, g_Windowing.GetMaxTextureSize()) : g_Windowing.GetMaxTextureSize();
// Read image into memory to use our vfs
XFILE::CFile file;
XFILE::auto_buffer buf;
if (file.LoadFile(texturePath, buf) <= 0)
return false;
IImage* pImage;
if(strMimeType.empty())
pImage = ImageFactory::CreateLoader(texturePath);
else
pImage = ImageFactory::CreateLoaderFromMimeType(strMimeType);
if (!LoadIImage(pImage, (unsigned char *)buf.get(), buf.size(), width, height, autoRotate))
{
delete pImage;
pImage = ImageFactory::CreateFallbackLoader(texturePath);
if (!LoadIImage(pImage, (unsigned char *)buf.get(), buf.size(), width, height))
{
CLog::Log(LOGDEBUG, "%s - Load of %s failed.", __FUNCTION__, texturePath.c_str());
delete pImage;
return false;
}
}
delete pImage;
return true;
}
示例4: while
std::vector< CStdString > CKaraokeLyricsTextUStar::readFile(const CStdString & lyricsFile, bool report_errors )
{
std::vector< CStdString > lines;
XFILE::CFile file;
XFILE::auto_buffer buf;
if (file.LoadFile(lyricsFile, buf) <= 0)
{
if (report_errors)
CLog::Log(LOGERROR, "%s: can't load \"%s\" file", __FUNCTION__, lyricsFile.c_str());
return std::vector< CStdString >();
}
file.Close();
const size_t lyricSize = buf.size();
// Parse into the string array
size_t offset = 0;
size_t lineoffset = 0;
while ( offset < lyricSize )
{
// End of line?
if (buf.get()[offset] == 0x0D || buf.get()[offset] == 0x0A)
{
// An empty line?
if ( lineoffset != offset )
lines.push_back(std::string(buf.get() + lineoffset, offset - lineoffset));
// Point to the next symbol
lineoffset = offset + 1;
}
offset++;
}
// Last line, if any
if ( lineoffset < lyricSize )
lines.push_back(std::string(buf.get() + lineoffset, buf.size() - lineoffset));
return lines;
}
示例5: Load
bool CKaraokeLyricsTextLRC::Load()
{
XFILE::CFile file;
// Clear the lyrics array
clearLyrics();
XFILE::auto_buffer buf;
if (file.LoadFile(m_lyricsFile, buf) <= 0)
{
CLog::Log(LOGERROR, "%s: can't load \"%s\" file", __FUNCTION__, m_lyricsFile.c_str());
return false;
}
file.Close();
// Parse the correction value
int timing_correction = MathUtils::round_int( g_advancedSettings.m_karaokeSyncDelayLRC * 10 );
unsigned int offset = 0;
CStdString songfilename = getSongFile();
// Skip windoze UTF8 file prefix, if any, and reject UTF16 files
if (buf.size() > 3)
{
if ((unsigned char)buf.get()[0] == 0xFF && (unsigned char)buf.get()[1] == 0xFE)
{
CLog::Log( LOGERROR, "LRC lyric loader: lyrics file is in UTF16 encoding, must be in UTF8" );
return false;
}
// UTF8 prefix added by some windoze apps
if ((unsigned char)buf.get()[0] == 0xEF && (unsigned char)buf.get()[1] == 0xBB && (unsigned char)buf.get()[2] == 0xBF)
offset = 3;
}
if (checkMultiTime(buf.get() + offset, buf.size() - offset))
return ParserMultiTime(buf.get() + offset, buf.size() - offset, timing_correction);
else
return ParserNormal(buf.get() + offset, buf.size() - offset, timing_correction);
}
示例6: Load
int CNfoFile::Load(const std::string& strFile)
{
Close();
XFILE::CFile file;
XFILE::auto_buffer buf;
if (file.LoadFile(strFile, buf) > 0)
{
m_doc.assign(buf.get(), buf.size());
m_headPos = 0;
return 0;
}
m_doc.clear();
return 1;
}
示例7: Open
bool CJpegIO::Open(const CStdString &texturePath, unsigned int minx, unsigned int miny, bool read)
{
Close();
m_texturePath = texturePath;
XFILE::CFile file;
XFILE::auto_buffer buf;
if (file.LoadFile(texturePath, buf) <= 0)
return false;
m_inputBuffSize = buf.size();
m_inputBuff = (unsigned char*)buf.detach();
return Read(m_inputBuff, m_inputBuffSize, minx, miny);
}
示例8: lock
const CTextureArray& CGUITextureManager::Load(const std::string& strTextureName, bool checkBundleOnly /*= false */)
{
std::string strPath;
static CTextureArray emptyTexture;
int bundle = -1;
int size = 0;
if (!HasTexture(strTextureName, &strPath, &bundle, &size))
return emptyTexture;
if (size) // we found the texture
{
for (int i = 0; i < (int)m_vecTextures.size(); ++i)
{
CTextureMap *pMap = m_vecTextures[i];
if (pMap->GetName() == strTextureName)
{
//CLog::Log(LOGDEBUG, "Total memusage %u", GetMemoryUsage());
return pMap->GetTexture();
}
}
// Whoops, not there.
return emptyTexture;
}
for (ilistUnused i = m_unusedTextures.begin(); i != m_unusedTextures.end(); ++i)
{
CTextureMap* pMap = i->first;
if (pMap->GetName() == strTextureName && i->second > 0)
{
m_vecTextures.push_back(pMap);
m_unusedTextures.erase(i);
return pMap->GetTexture();
}
}
if (checkBundleOnly && bundle == -1)
return emptyTexture;
//Lock here, we will do stuff that could break rendering
CSingleLock lock(g_graphicsContext);
#ifdef _DEBUG_TEXTURES
int64_t start;
start = CurrentHostCounter();
#endif
if (bundle >= 0 && StringUtils::EndsWithNoCase(strPath, ".gif"))
{
CTextureMap* pMap = nullptr;
CBaseTexture **pTextures = nullptr;
int nLoops = 0, width = 0, height = 0;
int* Delay = nullptr;
int nImages = m_TexBundle[bundle].LoadAnim(strTextureName, &pTextures, width, height, nLoops, &Delay);
if (!nImages)
{
CLog::Log(LOGERROR, "Texture manager unable to load bundled file: %s", strTextureName.c_str());
delete[] pTextures;
delete[] Delay;
return emptyTexture;
}
unsigned int maxWidth = 0;
unsigned int maxHeight = 0;
pMap = new CTextureMap(strTextureName, width, height, nLoops);
for (int iImage = 0; iImage < nImages; ++iImage)
{
pMap->Add(pTextures[iImage], Delay[iImage]);
maxWidth = std::max(maxWidth, pTextures[iImage]->GetWidth());
maxHeight = std::max(maxHeight, pTextures[iImage]->GetHeight());
}
pMap->SetWidth((int)maxWidth);
pMap->SetHeight((int)maxHeight);
delete[] pTextures;
delete[] Delay;
if (pMap)
{
m_vecTextures.push_back(pMap);
return pMap->GetTexture();
}
}
else if (StringUtils::EndsWithNoCase(strPath, ".gif") ||
StringUtils::EndsWithNoCase(strPath, ".apng"))
{
CTextureMap* pMap = nullptr;
std::string mimeType;
if (StringUtils::EndsWithNoCase(strPath, ".gif"))
mimeType = "image/gif";
else if (StringUtils::EndsWithNoCase(strPath, ".apng"))
mimeType = "image/apng";
XFILE::CFile file;
XFILE::auto_buffer buf;
CFFmpegImage anim(mimeType);
pMap = new CTextureMap(strTextureName, 0, 0, 0);
if (file.LoadFile(strPath, buf) <= 0 ||
//.........这里部分代码省略.........