remove all raw char type ref in code

This commit is contained in:
yyc12345 2023-09-17 10:38:46 +08:00
parent 23da6c9e3e
commit 230b18c0ba
17 changed files with 105 additions and 95 deletions

View File

@ -50,7 +50,7 @@ namespace LibCmo::CK2 {
/**
* @brief The identifier of Virtools file.
*/
constexpr const char CKNEMOFI[] = "Nemo Fi";
constexpr const CKCHAR CKNEMOFI[] = "Nemo Fi";
/**
* @brief Current Version of CK Engine (Day/Month/Year)
*/

View File

@ -11,10 +11,10 @@ namespace LibCmo::CK2 {
class CKBufferParser {
private:
char* m_MemBegin;
size_t m_MemPos;
CKBYTE* m_MemBegin;
CKDWORD m_MemPos;
bool m_NeedManualFree;
size_t m_MemSize;
CKDWORD m_MemSize;
public:
/**
@ -23,8 +23,8 @@ namespace LibCmo::CK2 {
* @param rsize The size of buffer.
* @param need_manual_free True if provided buffer need freed by CKBufferParser automatically.
*/
CKBufferParser(const void* ptr, size_t rsize, bool need_manual_free) :
m_MemBegin(const_cast<char*>(static_cast<const char*>(ptr))),
CKBufferParser(const void* ptr, CKDWORD rsize, bool need_manual_free) :
m_MemBegin(const_cast<CKBYTE*>(static_cast<const CKBYTE*>(ptr))),
m_MemPos(0u), m_MemSize(rsize),
m_NeedManualFree(need_manual_free)
{}
@ -32,8 +32,8 @@ namespace LibCmo::CK2 {
* @brief Create CKBufferParser from a new created buffer.
* @param newsize The size of new buffer.
*/
CKBufferParser(size_t newsize) :
m_MemBegin(new char[newsize]),
CKBufferParser(CKDWORD newsize) :
m_MemBegin(new CKBYTE[newsize]),
m_MemPos(0u), m_MemSize(newsize),
m_NeedManualFree(true)
{}
@ -42,21 +42,29 @@ namespace LibCmo::CK2 {
}
LIBCMO_DISABLE_COPY_MOVE(CKBufferParser);
const void* GetPtr(ptrdiff_t extraoff = 0) { return (this->m_MemBegin + m_MemPos + extraoff); }
void* GetMutablePtr(ptrdiff_t extraoff = 0) { return (this->m_MemBegin + m_MemPos + extraoff); }
void Read(void* data, size_t data_size) {
const void* GetPtr(CKINT extraoff = 0) { return (this->m_MemBegin + m_MemPos + extraoff); }
void* GetMutablePtr(CKINT extraoff = 0) { return (this->m_MemBegin + m_MemPos + extraoff); }
void* GetBase(void) { return this->m_MemBegin; }
CKDWORD GetSize(void) { return this->m_MemSize; }
CKDWORD GetCursor(void) { return this->m_MemPos; }
void MoveCursor(CKINT off) { this->m_MemPos += off; }
void SetCursor(CKDWORD off) { this->m_MemPos = off; }
void Read(void* data, CKDWORD data_size) {
std::memcpy(data, (this->m_MemBegin + m_MemPos), data_size);
this->m_MemPos += data_size;
}
void Write(const void* data, size_t data_size) {
template<class _Ty>
void Read(_Ty* data) {
Read(data, CKSizeof(_Ty));
}
void Write(const void* data, CKDWORD data_size) {
std::memcpy((this->m_MemBegin + m_MemPos), data, data_size);
this->m_MemPos += data_size;
}
void* GetBase(void) { return this->m_MemBegin; }
CKDWORD GetSize(void) { return static_cast<CKDWORD>(this->m_MemSize); }
CKDWORD GetCursor(void) { return static_cast<CKDWORD>(this->m_MemPos); }
void MoveCursor(ptrdiff_t off) { this->m_MemPos += off; }
void SetCursor(size_t off) { this->m_MemPos = off; }
template<class _Ty>
void Write(const _Ty* data) {
Write(data, CKSizeof(_Ty));
}
};
#pragma pack(push)

View File

@ -50,7 +50,7 @@ namespace LibCmo::CK2 {
if (std::memcmp(parser->GetPtr(), CKNEMOFI, sizeof(CKRawFileInfo::NeMo))) return CKERROR::CKERR_INVALIDFILE;
// read header
CKRawFileInfo rawHeader;
parser->Read(&rawHeader, sizeof(CKRawFileInfo));
parser->Read(&rawHeader);
// ========== header checker ==========
// check zero flag?
@ -120,12 +120,12 @@ namespace LibCmo::CK2 {
// read data
for (auto& fileobj : this->m_FileObjects) {
// read basic fields
parser->Read(&(fileobj.ObjectId), sizeof(CK_ID));
parser->Read(&(fileobj.ObjectCid), sizeof(CK_CLASSID));
parser->Read(&(fileobj.FileIndex), sizeof(CKDWORD));
parser->Read(&fileobj.ObjectId);
parser->Read(&fileobj.ObjectCid);
parser->Read(&fileobj.FileIndex);
CKDWORD namelen;
parser->Read(&namelen, sizeof(CKDWORD));
parser->Read(&namelen);
if (namelen != 0) {
name_conv.resize(namelen);
parser->Read(name_conv.data(), namelen);
@ -141,15 +141,15 @@ namespace LibCmo::CK2 {
if (this->m_FileInfo.FileVersion >= 8) {
// get size and resize
CKDWORD depSize;
parser->Read(&depSize, sizeof(CKDWORD));
parser->Read(&depSize);
this->m_PluginsDep.resize(depSize);
CKDWORD guid_size;
for (auto& dep : this->m_PluginsDep) {
// read category
parser->Read(&(dep.m_PluginCategory), sizeof(CK_PLUGIN_TYPE));
parser->Read(&dep.m_PluginCategory);
// get size and resize
parser->Read(&guid_size, sizeof(CKDWORD));
parser->Read(&guid_size);
dep.m_Guids.resize(guid_size);
// read data
if (guid_size != 0) {
@ -163,16 +163,16 @@ namespace LibCmo::CK2 {
// file ver >= 8 have this feature
if (this->m_FileInfo.FileVersion >= 8) {
// MARK: i don't knwo what is this!
int32_t hasIncludedFile;
parser->Read(&hasIncludedFile, sizeof(int32_t));
CKINT hasIncludedFile;
parser->Read(&hasIncludedFile);
if (hasIncludedFile > 0) {
// read included file size and resize
CKDWORD includedFileCount;
parser->Read(&includedFileCount, sizeof(CKDWORD));
parser->Read(&includedFileCount);
this->m_IncludedFiles.resize(includedFileCount);
hasIncludedFile -= static_cast<int32_t>(sizeof(CKDWORD));
hasIncludedFile -= static_cast<CKINT>(sizeof(CKDWORD));
}
// MARK: backward pos
@ -225,9 +225,9 @@ namespace LibCmo::CK2 {
// MARK: why read again? especially for file ver == 7.
// get save id max
parser->Read(&this->m_SaveIDMax, sizeof(int32_t));
parser->Read(&this->m_SaveIDMax);
// get object count and resize
parser->Read(&this->m_FileInfo.ObjectCount, sizeof(CKDWORD));
parser->Read(&this->m_FileInfo.ObjectCount);
if (this->m_FileObjects.empty()) {
this->m_FileObjects.resize(this->m_FileInfo.ObjectCount);
}
@ -242,10 +242,10 @@ namespace LibCmo::CK2 {
for (auto& mgr : this->m_ManagersData) {
// read guid
parser->Read(&(mgr.Manager), sizeof(CKGUID));
parser->Read(&mgr.Manager);
// read statechunk len
parser->Read(&stateChunkLen, sizeof(CKDWORD));
parser->Read(&stateChunkLen);
// check len
if (stateChunkLen == 0) {
mgr.Data = nullptr;
@ -270,7 +270,7 @@ namespace LibCmo::CK2 {
bool stateChkParseSuccess = false;
for (auto& obj : this->m_FileObjects) {
// get statechunk len
parser->Read(&obj.PackSize, sizeof(CKDWORD));
parser->Read(&obj.PackSize);
// check state chunk len
if (obj.PackSize == 0) {
obj.Data = nullptr;
@ -301,7 +301,7 @@ namespace LibCmo::CK2 {
for (auto& file : this->m_IncludedFiles) {
// get file name length and resize it
CKDWORD filenamelen = 0u;
parser->Read(&filenamelen, sizeof(CKDWORD));
parser->Read(&filenamelen);
name_conv.resize(filenamelen);
// read filename
@ -312,13 +312,13 @@ namespace LibCmo::CK2 {
// read file body length
CKDWORD filebodylen = 0u;
parser->Read(&filebodylen, sizeof(CKDWORD));
parser->Read(&filebodylen);
// read file body
XContainer::XString tempfilename = m_Ctx->GetPathManager()->GetTempFilePath(file.c_str());
FILE* fp = EncodingHelper::U8FOpen(tempfilename.c_str(), "wb");
if (fp != nullptr) {
std::fwrite(parser->GetPtr(), sizeof(char), filebodylen, fp);
std::fwrite(parser->GetPtr(), sizeof(CKBYTE), filebodylen, fp);
std::fclose(fp);
} else {
m_Ctx->OutputToConsoleEx("Fail to open temp file: %s", tempfilename.c_str());

View File

@ -126,7 +126,7 @@ namespace LibCmo::CK2 {
+ 2 * CKSizeof(CKDWORD);
}
CKDWORD sumHdrIncludedFiles = CKSizeof(int32_t) + CKSizeof(CKDWORD);
CKDWORD sumHdrIncludedFiles = CKSizeof(CKINT) + CKSizeof(CKDWORD);
// calc the whole size
CKDWORD sumHdrSize = sumHdrObjSize + sumHdrPlgSize + sumHdrIncludedFiles;
@ -173,14 +173,14 @@ namespace LibCmo::CK2 {
// todo: remove TOBEDELETED for referenced objects' m_ObjectFlags
hdrparser->Write(&obj.ObjectId, sizeof(CK_ID));
hdrparser->Write(&obj.ObjectCid, sizeof(CK_CLASSID));
hdrparser->Write(&obj.FileIndex, sizeof(CKDWORD));
hdrparser->Write(&obj.ObjectId);
hdrparser->Write(&obj.ObjectCid);
hdrparser->Write(&obj.FileIndex);
if (XContainer::NSXString::ToCKSTRING(obj.Name) != nullptr) {
m_Ctx->GetNativeString(obj.Name, name_conv);
CKDWORD namelen = static_cast<CKDWORD>(name_conv.size());
hdrparser->Write(&namelen, sizeof(CKDWORD));
hdrparser->Write(&namelen);
hdrparser->Write(name_conv.data(), namelen);
}
}
@ -188,13 +188,13 @@ namespace LibCmo::CK2 {
// write plugin dep
{
CKDWORD depsize = static_cast<CKDWORD>(m_PluginsDep.size());
hdrparser->Write(&depsize, sizeof(CKDWORD));
hdrparser->Write(&depsize);
for (auto& dep : m_PluginsDep) {
hdrparser->Write(&dep.m_PluginCategory, sizeof(CK_PLUGIN_TYPE));
CKDWORD guidsize = static_cast<CKDWORD>(dep.m_Guids.size());
hdrparser->Write(&guidsize, sizeof(CKDWORD));
hdrparser->Write(&guidsize);
hdrparser->Write(dep.m_Guids.data(), sizeof(CKGUID) * guidsize);
}
@ -203,10 +203,10 @@ namespace LibCmo::CK2 {
// write included file
{
CKDWORD cache = CKSizeof(CKDWORD);
hdrparser->Write(&cache, sizeof(CKDWORD));
hdrparser->Write(&cache);
cache = static_cast<CKDWORD>(m_IncludedFiles.size());
hdrparser->Write(&cache, sizeof(CKDWORD));
hdrparser->Write(&cache);
}
// compress header if needed
@ -230,22 +230,22 @@ namespace LibCmo::CK2 {
// write manager
for (auto& mgr : m_ManagersData) {
datparser->Write(&mgr.Manager, sizeof(CKGUID));
datparser->Write(&mgr.Manager);
CKDWORD writtenSize = 0;
if (mgr.Data != nullptr) {
writtenSize = mgr.Data->ConvertToBuffer(datparser->GetMutablePtr(sizeof(CKDWORD)));
writtenSize = mgr.Data->ConvertToBuffer(datparser->GetMutablePtr(CKSizeof(CKDWORD)));
delete mgr.Data;
mgr.Data = nullptr;
}
datparser->Write(&writtenSize, sizeof(CKDWORD));
datparser->Write(&writtenSize);
datparser->MoveCursor(writtenSize);
}
// write object
for (auto& obj : m_FileObjects) {
datparser->Write(&obj.PackSize, sizeof(CKDWORD));
datparser->Write(&obj.PackSize);
if (obj.Data != nullptr) {
obj.Data->ConvertToBuffer(datparser->GetMutablePtr());
@ -301,8 +301,8 @@ namespace LibCmo::CK2 {
if (fs == nullptr) return CKERROR::CKERR_CANTWRITETOFILE;
// write small header + header + data
std::fwrite(&rawHeader, sizeof(CKRawFileInfo), 1, fs);
std::fwrite(hdrparser->GetBase(), sizeof(char), hdrparser->GetSize(), fs);
std::fwrite(datparser->GetBase(), sizeof(char), datparser->GetSize(), fs);
std::fwrite(hdrparser->GetBase(), sizeof(CKBYTE), hdrparser->GetSize(), fs);
std::fwrite(datparser->GetBase(), sizeof(CKBYTE), datparser->GetSize(), fs);
// free buffer
hdrparser.reset();
datparser.reset();
@ -313,7 +313,7 @@ namespace LibCmo::CK2 {
m_Ctx->GetNativeString(fentry, name_conv);
CKDWORD filenamelen = static_cast<CKDWORD>(name_conv.size());
std::fwrite(&filenamelen, sizeof(CKDWORD), 1, fs);
std::fwrite(name_conv.data(), sizeof(char), filenamelen, fs);
std::fwrite(name_conv.data(), sizeof(CKBYTE), filenamelen, fs);
// try mapping file.
XContainer::XString tempfilename = m_Ctx->GetPathManager()->GetTempFilePath(fentry.c_str());
@ -324,7 +324,7 @@ namespace LibCmo::CK2 {
std::fwrite(&filebodylen, sizeof(CKDWORD), 1, fs);
// write file body
std::fwrite(mappedFile->GetBase(), sizeof(char), filebodylen, fs);
std::fwrite(mappedFile->GetBase(), sizeof(CKBYTE), filebodylen, fs);
} else {
// write zero file length
CKDWORD filebodylen = 0;

View File

@ -25,7 +25,7 @@ namespace LibCmo::CK2 {
void* CKPackData(const void* Data, CKDWORD size, CKDWORD& NewSize, CKINT compressionlevel) {
uLong boundary = compressBound(static_cast<uLong>(size));
char* DestBuffer = new char[boundary];
CKBYTE* DestBuffer = new CKBYTE[boundary];
uLongf _destLen = static_cast<uLongf>(boundary);
if (compress2(
@ -42,7 +42,7 @@ namespace LibCmo::CK2 {
}
void* CKUnPackData(CKDWORD DestSize, const void* SrcBuffer, CKDWORD SrcSize) {
char* DestBuffer = new char[DestSize];
CKBYTE* DestBuffer = new CKBYTE[DestSize];
uLongf cache = DestSize;
if (uncompress(

View File

@ -261,11 +261,11 @@ namespace LibCmo::CK2 {
// read chunk ver and data ver first
// chunk ver always set in the 3rd BYTE in every format
this->m_ChunkVersion = static_cast<CK_STATECHUNK_CHUNKVERSION>(
reinterpret_cast<const char*>(buf)[2]
reinterpret_cast<const CKBYTE*>(buf)[2]
);
// data ver always set in the 1st BYTE in every format
this->m_DataVersion = static_cast<CK_STATECHUNK_DATAVERSION>(
reinterpret_cast<const char*>(buf)[0]
reinterpret_cast<const CKBYTE*>(buf)[0]
);
// switch according to chunk ver
@ -336,11 +336,11 @@ namespace LibCmo::CK2 {
// re-read some extra data
// class id located the 2nd BYTE
this->m_ClassId = static_cast<CK_CLASSID>(
reinterpret_cast<const char*>(buf)[1]
reinterpret_cast<const CKBYTE*>(buf)[1]
);
// options located the 4th BYTE
CK_STATECHUNK_CHUNKOPTIONS options = static_cast<CK_STATECHUNK_CHUNKOPTIONS>(
reinterpret_cast<const char*>(buf)[3]
reinterpret_cast<const CKBYTE*>(buf)[3]
);
// read normal data
@ -410,10 +410,10 @@ namespace LibCmo::CK2 {
// if buffer provided, write it
if (buf != nullptr) {
// write header
reinterpret_cast<char*>(buf)[0] = static_cast<char>(this->m_DataVersion);
reinterpret_cast<char*>(buf)[1] = static_cast<char>(this->m_ClassId);
reinterpret_cast<char*>(buf)[2] = static_cast<char>(this->m_ChunkVersion);
reinterpret_cast<char*>(buf)[3] = static_cast<char>(options);
reinterpret_cast<CKBYTE*>(buf)[0] = static_cast<CKBYTE>(this->m_DataVersion);
reinterpret_cast<CKBYTE*>(buf)[1] = static_cast<CKBYTE>(this->m_ClassId);
reinterpret_cast<CKBYTE*>(buf)[2] = static_cast<CKBYTE>(this->m_ChunkVersion);
reinterpret_cast<CKBYTE*>(buf)[3] = static_cast<CKBYTE>(options);
CKDWORD* dwbuf = reinterpret_cast<CKDWORD*>(buf);
// write buffer length
@ -454,7 +454,7 @@ namespace LibCmo::CK2 {
// // dwSize store the length of compressed buffer as CHAR size, not DWORD size!
// // create a enough buffer
// char* buffer = new char[DestSize];
// CKBYTE* buffer = new CKBYTE[DestSize];
// uLongf destSize = DestSize;
// // uncompress it
// auto err = uncompress(
@ -776,7 +776,7 @@ namespace LibCmo::CK2 {
}
// create buffer
*buf = new char[bufByteSize];
*buf = new CKBYTE[bufByteSize];
// read data
if (!this->ReadByteData(*buf, bufByteSize)) {
@ -813,12 +813,12 @@ namespace LibCmo::CK2 {
void CKStateChunk::BufferDeleter::operator()(void* buf) {
if (buf == nullptr) return;
delete[] reinterpret_cast<const char*>(buf);
delete[] reinterpret_cast<const CKBYTE*>(buf);
}
void CKStateChunk::DeleteBuffer(const void* buf) {
if (buf == nullptr) return;
delete[] reinterpret_cast<const char*>(buf);
delete[] reinterpret_cast<const CKBYTE*>(buf);
}
/* ========== Sequence Functions ==========*/

View File

@ -36,7 +36,7 @@ namespace LibCmo::CK2 {
~CKStateChunk();
private:
enum class CKStateChunkStatus : int32_t {
enum class CKStateChunkStatus : CKDWORD {
IDLE,
READ,
WRITE

View File

@ -12,8 +12,8 @@ namespace LibCmo::CK2::DataHandlers {
*/
static void ABGRToARGB(CKDWORD count, const void* _abgr, void* _argb) {
const char* abgr = reinterpret_cast<const char*>(_abgr);
char* argb = reinterpret_cast<char*>(_argb);
const CKBYTE* abgr = static_cast<const CKBYTE*>(_abgr);
CKBYTE* argb = static_cast<CKBYTE*>(_argb);
// copy R
VxMath::VxCopyStructure(
count,
@ -53,8 +53,8 @@ namespace LibCmo::CK2::DataHandlers {
}
static void ARGBToABGR(CKDWORD count, const void* _argb, void* _abgr) {
const char* argb = reinterpret_cast<const char*>(_argb);
char* abgr = reinterpret_cast<char*>(_abgr);
const CKBYTE* argb = static_cast<const CKBYTE*>(_argb);
CKBYTE* abgr = static_cast<CKBYTE*>(_abgr);
// copy R
VxMath::VxCopyStructure(
count,
@ -147,7 +147,7 @@ namespace LibCmo::CK2::DataHandlers {
static void FileWriteFunction(void* context, void* data, int size) {
FileSaveContext* ctx = reinterpret_cast<FileSaveContext*>(context);
if (ctx->m_Fs != nullptr) {
std::fwrite(data, sizeof(char), size, ctx->m_Fs);
std::fwrite(data, sizeof(CKBYTE), size, ctx->m_Fs);
}
ctx->m_Counter += size;
}
@ -161,7 +161,7 @@ namespace LibCmo::CK2::DataHandlers {
MemorySaveContext* ctx = reinterpret_cast<MemorySaveContext*>(context);
if (ctx->m_Mem != nullptr) {
std::memcpy(ctx->m_Mem, data, size);
ctx->m_Mem = reinterpret_cast<char*>(ctx->m_Mem) + size;
ctx->m_Mem = static_cast<CKBYTE*>(ctx->m_Mem) + size;
}
ctx->m_Counter += size;
}

View File

@ -90,7 +90,7 @@ namespace LibCmo::CK2::MgrImpls {
data for your manager.
@see CKStateChunk, LoadData
*/
virtual bool SaveData(CKStateChunk* chunk, CKFileVisitor* SavedFile) {
virtual bool SaveData(LIBCMO_UNUSED CKStateChunk* chunk, LIBCMO_UNUSED CKFileVisitor* SavedFile) {
return false; // default value is false to indicate this manager do not need save any data.
}
/**
@ -102,7 +102,7 @@ namespace LibCmo::CK2::MgrImpls {
+ During a load operation, each manager is automatically called if there was a chunk saved in the file with SaveData.
@see CKStateChunk, SaveData
*/
virtual CKERROR LoadData(CKStateChunk* chunk, CKFileVisitor* LoadedFile) {
virtual CKERROR LoadData(LIBCMO_UNUSED CKStateChunk* chunk, LIBCMO_UNUSED CKFileVisitor* LoadedFile) {
return CKERROR::CKERR_OK;
}
@ -138,7 +138,7 @@ namespace LibCmo::CK2::MgrImpls {
CKMANAGER_FUNC_OnSequenceToBeDeleted for this function to get called.
@see Main Virtools Events, CKContext::DestroyObjects, SequenceDeleted
*/
virtual CKERROR SequenceToBeDeleted(const CK_ID* objids, CKDWORD count) { return CKERROR::CKERR_OK; }
virtual CKERROR SequenceToBeDeleted(LIBCMO_UNUSED const CK_ID* objids, LIBCMO_UNUSED CKDWORD count) { return CKERROR::CKERR_OK; }
/**
@brief Called after objects have been deleted.
@return CK_OK if successful or an error code otherwise.
@ -150,7 +150,7 @@ namespace LibCmo::CK2::MgrImpls {
CKMANAGER_FUNC_OnSequenceDeleted for this function to get called.
@see Main Virtools Events, CKContext::DestroyObjects, SequenceToBeDeleted
*/
virtual CKERROR SequenceDeleted(const CK_ID* objids, CKDWORD count) { return CKERROR::CKERR_OK; }
virtual CKERROR SequenceDeleted(LIBCMO_UNUSED const CK_ID* objids, LIBCMO_UNUSED CKDWORD count) { return CKERROR::CKERR_OK; }
protected:

View File

@ -106,7 +106,7 @@ namespace LibCmo::CK2::ObjImpls {
// MARK: I ignore 0x4 in there because it involve video.
// set current slot, transparent color, and video format.
CKDWORD currentSlot, transColor, videoFmt;
CKDWORD currentSlot, transColor;
fmtbytesize -= CKSizeof(CKDWORD);
switch (fmtbytesize) {
case (3 * sizeof(CKDWORD)):

View File

@ -67,6 +67,8 @@
#pragma endregion
#define LIBCMO_UNUSED [[maybe_unused]]
namespace LibCmo {
[[noreturn]] void LibPanic(int line, const char* file, const char* errmsg);

View File

@ -12,8 +12,8 @@ namespace LibCmo::VxMath {
void VxCopyStructure(CKDWORD Count, void* Dst, CKDWORD OutStride, CKDWORD SizeSrc, const void* Src, CKDWORD InStride) {
if (Dst == nullptr || Src == nullptr) return;
char* cdst = reinterpret_cast<char*>(Dst);
const char* csrc = reinterpret_cast<const char*>(Src);
CKBYTE* cdst = static_cast<CKBYTE*>(Dst);
const CKBYTE* csrc = static_cast<const CKBYTE*>(Src);
for (CKDWORD i = 0; i < Count; ++i) {
std::memcpy(cdst, csrc, SizeSrc);
cdst += OutStride;

View File

@ -3,7 +3,7 @@
namespace LibCmo::VxMath {
VxMemoryMappedFile::VxMemoryMappedFile(const char* u8_filepath) :
VxMemoryMappedFile::VxMemoryMappedFile(CKSTRING u8_filepath) :
// init members
#if defined(LIBCMO_OS_WIN32)
m_hFile(NULL), m_hFileMapping(NULL), m_hFileMapView(NULL),

View File

@ -40,7 +40,7 @@ namespace LibCmo::VxMath {
size_t m_cbFile;
bool m_bIsValid;
public:
VxMemoryMappedFile(const char* u8_filepath);
VxMemoryMappedFile(CKSTRING u8_filepath);
VxMemoryMappedFile(const VxMemoryMappedFile&) = delete;
VxMemoryMappedFile& operator=(const VxMemoryMappedFile&) = delete;
~VxMemoryMappedFile(void);

View File

@ -10,7 +10,7 @@ namespace Unvirt::StructFormatter {
#define PRIuSIZET "zu"
static void PrintCKSTRING(LibCmo::CK2::CKSTRING name) {
static void PrintCKSTRING(LibCmo::CKSTRING name) {
if (name == nullptr) {
fputs(UNVIRT_TERMCOL_LIGHT_MAGENTA(("<anonymous>")), stdout);
} else {
@ -70,7 +70,7 @@ namespace Unvirt::StructFormatter {
(fileinfo.CKVersion >> 0) & 0xFFFF
);
LibCmo::CK2::CKDWORD product_series[4] {
LibCmo::CKDWORD product_series[4] {
(fileinfo.ProductBuild >> 24) & 0xFF,
(fileinfo.ProductBuild >> 16) & 0xFF,
(fileinfo.ProductBuild >> 8) & 0xFF,
@ -136,7 +136,7 @@ namespace Unvirt::StructFormatter {
fputc('\t', stdout);
PrintPointer(obj.Data);
fputc('\t', stdout);
PrintCKSTRING(obj.Name.toCKSTRING());
PrintCKSTRING(LibCmo::XContainer::NSXString::ToCKSTRING(obj.Name));
fputc('\n', stdout);
}
);
@ -201,12 +201,12 @@ namespace Unvirt::StructFormatter {
fputc('\n', stdout);
fprintf(stdout, "Version (Data / Chunk): %" PRIuCKDWORD " (%s) / %" PRIuCKDWORD " (%s)\n",
static_cast<LibCmo::CK2::CKDWORD>(profile.m_DataVersion), AccessibleValue::GetEnumName(profile.m_DataVersion, AccessibleValue::EnumDesc::CK_STATECHUNK_DATAVERSION).c_str(),
static_cast<LibCmo::CK2::CKDWORD>(profile.m_ChunkVersion), AccessibleValue::GetEnumName(profile.m_ChunkVersion, AccessibleValue::EnumDesc::CK_STATECHUNK_CHUNKVERSION).c_str());
static_cast<LibCmo::CKDWORD>(profile.m_DataVersion), AccessibleValue::GetEnumName(profile.m_DataVersion, AccessibleValue::EnumDesc::CK_STATECHUNK_DATAVERSION).c_str(),
static_cast<LibCmo::CKDWORD>(profile.m_ChunkVersion), AccessibleValue::GetEnumName(profile.m_ChunkVersion, AccessibleValue::EnumDesc::CK_STATECHUNK_CHUNKVERSION).c_str());
fprintf(stdout, "List (Object / Chunk / Manager): %" PRIuCKDWORD " / %" PRIuCKDWORD " / %" PRIuCKDWORD "\n",
static_cast<LibCmo::CK2::CKDWORD>(profile.m_ObjectListSize),
static_cast<LibCmo::CK2::CKDWORD>(profile.m_ChunkListSize),
static_cast<LibCmo::CK2::CKDWORD>(profile.m_ManagerListSize));
static_cast<LibCmo::CKDWORD>(profile.m_ObjectListSize),
static_cast<LibCmo::CKDWORD>(profile.m_ChunkListSize),
static_cast<LibCmo::CKDWORD>(profile.m_ManagerListSize));
fputs("Data: ", stdout);
PrintPointer(profile.m_pData);
@ -231,7 +231,7 @@ namespace Unvirt::StructFormatter {
PrintPointer(ident.m_DataPtr);
fputc('\t', stdout);
fprintf(stdout, "%" PRIuCKDWORD " (%" PRIuCKDWORD " DWORD + %" PRIuCKDWORD ")\n",
ident.m_AreaSize, ident.m_AreaSize / CKSizeof(LibCmo::CK2::CKDWORD), ident.m_AreaSize % CKSizeof(LibCmo::CK2::CKDWORD));
ident.m_AreaSize, ident.m_AreaSize / CKSizeof(LibCmo::CKDWORD), ident.m_AreaSize % CKSizeof(LibCmo::CKDWORD));
}
}

View File

@ -173,7 +173,7 @@ namespace Unvirt::Context {
m_Ctx->ClearAll();
}
void UnvirtContext::PrintContextMsg(LibCmo::CK2::CKSTRING msg) {
void UnvirtContext::PrintContextMsg(LibCmo::CKSTRING msg) {
if (msg != nullptr) {
fprintf(stdout, UNVIRT_TERMCOL_LIGHT_YELLOW(("[CKContext] ")) "%s\n", msg);
}

View File

@ -44,7 +44,7 @@ namespace Unvirt::Context {
protected:
bool HasOpenedFile();
void ClearDocument();
void PrintContextMsg(LibCmo::CK2::CKSTRING msg);
void PrintContextMsg(LibCmo::CKSTRING msg);
CmdHelper::CommandRoot m_Root;
CmdHelper::HelpDocument* m_Help;