本文整理汇总了C++中mem8_ptr_t::IsGood方法的典型用法代码示例。如果您正苦于以下问题:C++ mem8_ptr_t::IsGood方法的具体用法?C++ mem8_ptr_t::IsGood怎么用?C++ mem8_ptr_t::IsGood使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mem8_ptr_t
的用法示例。
在下文中一共展示了mem8_ptr_t::IsGood方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UTF16stoUTF8s
int UTF16stoUTF8s(mem16_ptr_t utf16, mem64_t utf16_len, mem8_ptr_t utf8, mem64_t utf8_len)
{
cellL10n.Warning("UTF16stoUTF8s(utf16_addr=0x%x, utf16_len_addr=0x%x, utf8_addr=0x%x, utf8_len_addr=0x%x)",
utf16.GetAddr(), utf16_len.GetAddr(), utf8.GetAddr(), utf8_len.GetAddr());
if (!utf16.IsGood() || !utf16_len.IsGood() || !utf8_len.IsGood())
return SRCIllegal;
std::u16string wstr =(char16_t*)Memory.VirtualToRealAddr(utf16);
wstr.resize(utf16_len.GetValue()); // TODO: Is this really the role of utf16_len in this function?
#ifdef _MSC_VER
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert;
std::string str = convert.to_bytes(wstr);
if (!utf8.IsGood() || utf8_len.GetValue() < str.size())
{
utf8_len = str.size();
return DSTExhausted;
}
utf8_len = str.size();
Memory.WriteString(utf8, str.c_str());
#endif
return ConversionOK;
}
示例2: UTF16stoUTF8s
int UTF16stoUTF8s(mem16_ptr_t utf16, mem64_t utf16_len, mem8_ptr_t utf8, mem64_t utf8_len)
{
cellL10n.Warning("UTF16stoUTF8s(utf16_addr=0x%x, utf16_len_addr=0x%x, utf8_addr=0x%x, utf8_len_addr=0x%x)",
utf16.GetAddr(), utf16_len.GetAddr(), utf8.GetAddr(), utf8_len.GetAddr());
if (!utf16.IsGood() || !utf16_len.IsGood() || !utf8_len.IsGood())
return SRCIllegal;
std::wstring wstr = (wchar_t*)Memory.VirtualToRealAddr(utf16);
std::string str;
int len = min((int)utf16_len.GetValue(), (int)wstr.size());
int size = (int)WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), len, 0, 0, NULL, NULL);
if (!utf8.IsGood())
utf8_len = size;
if (utf8_len.GetValue() < size)
return DSTExhausted;
#ifdef WIN32
WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), len, &str[0], size, NULL, NULL);
#else
// TODO
#endif
Memory.WriteString(utf8, str);
return ConversionOK;
}
示例3: cellGifDecDecodeData
int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_ptr_t<CellGifDecDataCtrlParam> dataCtrlParam, mem_ptr_t<CellGifDecDataOutInfo> dataOutInfo)
{
if (!data.IsGood() || !dataCtrlParam.IsGood() || !dataOutInfo.IsGood())
return CELL_GIFDEC_ERROR_ARG;
dataOutInfo->status = CELL_GIFDEC_DEC_STATUS_STOP;
CellGifDecSubHandle* subHandle_data;
if(!cellGifDec->CheckId(subHandle, subHandle_data))
return CELL_GIFDEC_ERROR_FATAL;
const u32& fd = subHandle_data->fd;
const u64& fileSize = subHandle_data->fileSize;
const CellGifDecOutParam& current_outParam = subHandle_data->outParam;
//Copy the GIF file to a buffer
MemoryAllocator<unsigned char> gif(fileSize);
MemoryAllocator<u64> pos, nread;
cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
cellFsRead(fd, gif.GetAddr(), gif.GetSize(), nread);
//Decode GIF file. (TODO: Is there any faster alternative? Can we do it without external libraries?)
int width, height, actual_components;
std::shared_ptr<unsigned char> image(stbi_load_from_memory(gif, fileSize, &width, &height, &actual_components, 4));
if (!image)
return CELL_GIFDEC_ERROR_STREAM_FORMAT;
uint image_size = width * height * 4;
switch((u32)current_outParam.outputColorSpace)
{
case CELL_GIFDEC_RGBA:
if (!Memory.CopyFromReal(data.GetAddr(), image.get(), image_size))
{
cellGifDec->Error("cellGifDecDecodeData() failed (dataa_addr=0x%x)", data.GetAddr());
return CELL_EFAULT;
}
break;
case CELL_GIFDEC_ARGB:
for(uint i = 0; i < image_size; i+=4)
{
data += image.get()[i+3];
data += image.get()[i+0];
data += image.get()[i+1];
data += image.get()[i+2];
}
break;
default:
return CELL_GIFDEC_ERROR_ARG;
}
dataOutInfo->status = CELL_GIFDEC_DEC_STATUS_FINISH;
dataOutInfo->recordType = CELL_GIFDEC_RECORD_TYPE_IMAGE_DESC;
return CELL_OK;
}
示例4: jstrchk
int jstrchk(mem8_ptr_t jstr)
{
if (!jstr.IsGood())
cellL10n.Error("jstrchk(jstr_addr=0x%x): invalid address", jstr.GetAddr());
else if (jstr[0])
cellL10n.Log("jstrchk(jstr_addr=0x%x): utf-8: [%s]", jstr.GetAddr(), Memory.ReadString(jstr.GetAddr()).c_str());
else
cellL10n.Log("jstrchk(jstr_addr=0x%x): empty string", jstr.GetAddr());
return L10N_STR_UTF8;
}
示例5: cellPngDecDecodeData
int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_ptr_t<CellPngDecDataCtrlParam> dataCtrlParam, mem_ptr_t<CellPngDecDataOutInfo> dataOutInfo)
{
if (!data.IsGood() || !dataCtrlParam.IsGood() || !dataOutInfo.IsGood())
return CELL_PNGDEC_ERROR_ARG;
dataOutInfo->status = CELL_PNGDEC_DEC_STATUS_STOP;
CellPngDecSubHandle* subHandle_data;
if(!cellPngDec.CheckId(subHandle, subHandle_data))
return CELL_PNGDEC_ERROR_FATAL;
const u32& fd = subHandle_data->fd;
const u64& fileSize = subHandle_data->fileSize;
const CellPngDecOutParam& current_outParam = subHandle_data->outParam;
//Copy the PNG file to a buffer
MemoryAllocator<unsigned char> png(fileSize);
MemoryAllocator<u64> pos, nread;
switch(subHandle_data->src.srcSelect.ToLE())
{
case CELL_PNGDEC_BUFFER:
Memory.Copy(png.GetAddr(), subHandle_data->src.streamPtr.ToLE(), png.GetSize());
break;
case CELL_PNGDEC_FILE:
cellFsLseek(fd, 0, CELL_SEEK_SET, pos.GetAddr());
cellFsRead(fd, png.GetAddr(), png.GetSize(), nread.GetAddr());
break;
}
//Decode PNG file. (TODO: Is there any faster alternative? Can we do it without external libraries?)
int width, height, actual_components;
auto image = std::unique_ptr<unsigned char,decltype(&::free)>
(
stbi_load_from_memory(png.GetPtr(), fileSize, &width, &height, &actual_components, 4),
&::free
);
if (!image) return CELL_PNGDEC_ERROR_STREAM_FORMAT;
uint image_size = width * height;
switch((u32)current_outParam.outputColorSpace)
{
case CELL_PNGDEC_RGB:
case CELL_PNGDEC_RGBA:
{
const char nComponents = (CELL_PNGDEC_RGBA ? 4 : 3);
image_size *= nComponents;
if (dataCtrlParam->outputBytesPerLine > width * nComponents) //check if we need padding
{
//TODO: find out if we can't do padding without an extra copy
char *output = (char *) malloc(dataCtrlParam->outputBytesPerLine*height);
for (int i = 0; i < height; i++)
{
memcpy(&output[i*dataCtrlParam->outputBytesPerLine], &image.get()[width*nComponents*i], width*nComponents);
}
Memory.CopyFromReal(data.GetAddr(), output, dataCtrlParam->outputBytesPerLine*height);
free(output);
}
else
{
Memory.CopyFromReal(data.GetAddr(), image.get(), image_size);
}
}
break;
case CELL_PNGDEC_ARGB:
{
const char nComponents = 4;
image_size *= nComponents;
if (dataCtrlParam->outputBytesPerLine > width * nComponents) //check if we need padding
{
//TODO: find out if we can't do padding without an extra copy
char *output = (char *) malloc(dataCtrlParam->outputBytesPerLine*height);
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width * nComponents; j += nComponents){
output[i*dataCtrlParam->outputBytesPerLine + j ] = image.get()[i*width * nComponents + j + 3];
output[i*dataCtrlParam->outputBytesPerLine + j + 1] = image.get()[i*width * nComponents + j + 0];
output[i*dataCtrlParam->outputBytesPerLine + j + 2] = image.get()[i*width * nComponents + j + 1];
output[i*dataCtrlParam->outputBytesPerLine + j + 3] = image.get()[i*width * nComponents + j + 2];
}
}
Memory.CopyFromReal(data.GetAddr(), output, dataCtrlParam->outputBytesPerLine*height);
free(output);
}
else
{
for (uint i = 0; i < image_size; i += nComponents)
{
data += image.get()[i + 3];
data += image.get()[i + 0];
data += image.get()[i + 1];
data += image.get()[i + 2];
}
}
}
break;
case CELL_PNGDEC_GRAYSCALE:
case CELL_PNGDEC_PALETTE:
case CELL_PNGDEC_GRAYSCALE_ALPHA:
//.........这里部分代码省略.........
示例6: cellJpgDecDecodeData
int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const mem_ptr_t<CellJpgDecDataCtrlParam> dataCtrlParam, mem_ptr_t<CellJpgDecDataOutInfo> dataOutInfo)
{
if (!data.IsGood() || !dataCtrlParam.IsGood() || !dataOutInfo.IsGood())
return CELL_JPGDEC_ERROR_ARG;
dataOutInfo->status = CELL_JPGDEC_DEC_STATUS_STOP;
CellJpgDecSubHandle* subHandle_data;
if(!cellJpgDec.CheckId(subHandle, subHandle_data))
return CELL_JPGDEC_ERROR_FATAL;
const u32& fd = subHandle_data->fd;
const u64& fileSize = subHandle_data->fileSize;
const CellJpgDecOutParam& current_outParam = subHandle_data->outParam;
//Copy the JPG file to a buffer
MemoryAllocator<unsigned char> jpg(fileSize);
MemoryAllocator<u64> pos, nread;
cellFsLseek(fd, 0, CELL_SEEK_SET, pos);
cellFsRead(fd, jpg.GetAddr(), jpg.GetSize(), nread);
//Decode JPG file. (TODO: Is there any faster alternative? Can we do it without external libraries?)
int width, height, actual_components;
std::shared_ptr<unsigned char> image(stbi_load_from_memory(jpg, fileSize, &width, &height, &actual_components, 4));
if (!image) return CELL_JPGDEC_ERROR_STREAM_FORMAT;
uint image_size = width * height;
switch((u32)current_outParam.outputColorSpace)
{
case CELL_JPG_RGBA:
case CELL_JPG_RGB:
image_size *= current_outParam.outputColorSpace == CELL_JPG_RGBA ? 4 : 3;
Memory.CopyFromReal(data.GetAddr(), image.get(), image_size);
break;
case CELL_JPG_ARGB:
image_size *= 4;
for(u32 i = 0; i < image_size; i+=4)
{
data += image.get()[i+3];
data += image.get()[i+0];
data += image.get()[i+1];
data += image.get()[i+2];
}
break;
case CELL_JPG_GRAYSCALE:
case CELL_JPG_YCbCr:
case CELL_JPG_UPSAMPLE_ONLY:
case CELL_JPG_GRAYSCALE_TO_ALPHA_RGBA:
case CELL_JPG_GRAYSCALE_TO_ALPHA_ARGB:
cellJpgDec.Error("cellJpgDecDecodeData: Unsupported color space (%d)", current_outParam.outputColorSpace.ToLE());
break;
default:
return CELL_JPGDEC_ERROR_ARG;
}
dataOutInfo->status = CELL_JPGDEC_DEC_STATUS_FINISH;
if(dataCtrlParam->outputBytesPerLine)
dataOutInfo->outputLines = image_size / dataCtrlParam->outputBytesPerLine;
return CELL_OK;
}