diff --git a/LibCmo/CK2/CKContext.cpp b/LibCmo/CK2/CKContext.cpp index 30a084b..03622e2 100644 --- a/LibCmo/CK2/CKContext.cpp +++ b/LibCmo/CK2/CKContext.cpp @@ -1,5 +1,5 @@ #include "CKContext.hpp" -#include "CKObjectImplements/CKObject.hpp" +#include "ObjImpls/CKObject.hpp" #include namespace LibCmo::CK2 { @@ -12,7 +12,7 @@ namespace LibCmo::CK2 { #pragma region Objects Management - CKObject* CKContext::CreateCKObject(CK_CLASSID cls, CKSTRING name, + ObjImpls::CKObject* CKContext::CreateCKObject(CK_CLASSID cls, CKSTRING name, CK_OBJECTCREATION_OPTIONS options, CK_CREATIONMODE* res) { // todo: Process paramter options and res @@ -33,7 +33,7 @@ namespace LibCmo::CK2 { } // create one - CKObject* obj = desc->CreationFct(this, decided_id, name); + ObjImpls::CKObject* obj = desc->CreationFct(this, decided_id, name); // put into slot m_ObjectsList[decided_id] = obj; @@ -42,7 +42,7 @@ namespace LibCmo::CK2 { return obj; } - CKObject* CKContext::GetCKObject(CK_ID id) { + ObjImpls::CKObject* CKContext::GetCKObject(CK_ID id) { if (id >= m_ObjectsList.size()) return nullptr; return m_ObjectsList[id]; } @@ -52,7 +52,7 @@ namespace LibCmo::CK2 { * @param[in] ctx The CKContext * @param[in] obj The CKObject need to be free. */ - static void InternalDestroy(CKContext* ctx, CKObject* obj) { + static void InternalDestroy(CKContext* ctx, ObjImpls::CKObject* obj) { // find desc by classid // if really we can not find it, we only can delete it directly. const CKClassDesc* desc = CKGetClassDesc(obj->GetClassID()); @@ -68,7 +68,7 @@ namespace LibCmo::CK2 { if (id >= m_ObjectsList.size()) return; // get object and free it - CKObject* obj = m_ObjectsList[id]; + ObjImpls::CKObject* obj = m_ObjectsList[id]; if (obj == nullptr) return; InternalDestroy(this, obj); @@ -103,8 +103,6 @@ namespace LibCmo::CK2 { } } - // todo: free all created managers - } #pragma endregion diff --git a/LibCmo/CK2/CKContext.hpp b/LibCmo/CK2/CKContext.hpp index 67a4f52..d8a423d 100644 --- a/LibCmo/CK2/CKContext.hpp +++ b/LibCmo/CK2/CKContext.hpp @@ -37,10 +37,10 @@ namespace LibCmo::CK2 { * @remark CKObjects must be destroy with the DestroyObject method. * @see CKObject, DestroyObject */ - CKObject* CreateCKObject(CK_CLASSID cls, CKSTRING name, + ObjImpls::CKObject* CreateCKObject(CK_CLASSID cls, CKSTRING name, CK_OBJECTCREATION_OPTIONS options = CK_OBJECTCREATION_OPTIONS::CK_OBJECTCREATION_NONAMECHECK, CK_CREATIONMODE* res = nullptr); - CKObject* GetCKObject(CK_ID id); + ObjImpls::CKObject* GetCKObject(CK_ID id); void DestroyCKObject(CK_ID id); // ========== Object Access ========== @@ -77,7 +77,7 @@ namespace LibCmo::CK2 { protected: // ========== Objects Management ========== - XContainer::XArray m_ObjectsList; + XContainer::XArray m_ObjectsList; std::deque m_ReturnedObjectIds; // ========== Encoding utilities ========== diff --git a/LibCmo/CK2/CKDefines.hpp b/LibCmo/CK2/CKDefines.hpp index 7f182a9..56986a2 100644 --- a/LibCmo/CK2/CKDefines.hpp +++ b/LibCmo/CK2/CKDefines.hpp @@ -22,8 +22,8 @@ namespace LibCmo::CK2 { // ========== Class registration utilities ========== //using CKClassRegisterFct = std::function; - using CKClassCreationFct = std::function; - using CKClassReleaseFct = std::function; + using CKClassCreationFct = std::function; + using CKClassReleaseFct = std::function; using CKClassNameFct = std::function; //using CKClassDependenciesFct = std::function; //using CKClassDependenciesCountFct = std::function; @@ -63,10 +63,7 @@ namespace LibCmo::CK2 { DerivationLevel(0), Parents(), Children() {} - CKClassDesc(const CKClassDesc& rhs) = default; - CKClassDesc(CKClassDesc&& rhs) = default; - CKClassDesc& operator=(const CKClassDesc& rhs) = default; - CKClassDesc& operator=(CKClassDesc& rhs) = default; + LIBCMO_DEFAULT_COPY_MOVE(CKClassDesc); }; } diff --git a/LibCmo/CK2/CKFile.hpp b/LibCmo/CK2/CKFile.hpp index 54bc3bf..752cc6a 100644 --- a/LibCmo/CK2/CKFile.hpp +++ b/LibCmo/CK2/CKFile.hpp @@ -104,7 +104,7 @@ namespace LibCmo::CK2 { CK_ID ObjectId; /**< ID of the object being load/saved (as it will be/was saved in the file) */ CK_ID CreatedObjectId; /**< ID of the object being created */ CK_CLASSID ObjectCid; /**< Class Identifier of the object */ - CKObject* ObjPtr; /**< A pointer to the object itself (as CreatedObject when loading) */ + ObjImpls::CKObject* ObjPtr; /**< A pointer to the object itself (as CreatedObject when loading) */ TypeHelper::MKString Name; /**< Name of the Object */ CKStateChunk* Data; /**< A CKStateChunk that contains object information */ //CKINT PostPackSize; /**< When compressed chunk by chunk : size of Data after compression */ @@ -197,7 +197,7 @@ namespace LibCmo::CK2 { LIBCMO_DISABLE_COPY_MOVE(CKFileWriter); // ========== Saving Preparing ========== - CKBOOL AddSavedObject(CKObject* obj, CKDWORD flags = CK_STATESAVE_ALL); + CKBOOL AddSavedObject(ObjImpls::CKObject* obj, CKDWORD flags = CK_STATESAVE_ALL); CKBOOL AddSavedObjects(CKObjectArray* objarray, CKDWORD flags = CK_STATESAVE_ALL); CKBOOL AddSavedFile(CKSTRING u8FileName); diff --git a/LibCmo/CK2/CKFileOthers.cpp b/LibCmo/CK2/CKFileOthers.cpp index 201926f..39fac7e 100644 --- a/LibCmo/CK2/CKFileOthers.cpp +++ b/LibCmo/CK2/CKFileOthers.cpp @@ -149,7 +149,7 @@ namespace LibCmo::CK2 { CKFileWriter::~CKFileWriter() {} - CKBOOL CKFileWriter::AddSavedObject(CKObject* obj, CKDWORD flags) { + CKBOOL CKFileWriter::AddSavedObject(ObjImpls::CKObject* obj, CKDWORD flags) { return CKFALSE; } diff --git a/LibCmo/CK2/CKFileReader.cpp b/LibCmo/CK2/CKFileReader.cpp index 4724ac0..f3fbd1a 100644 --- a/LibCmo/CK2/CKFileReader.cpp +++ b/LibCmo/CK2/CKFileReader.cpp @@ -1,6 +1,6 @@ #include "CKFile.hpp" #include "CKStateChunk.hpp" -#include "CKObjectImplements/CKObject.hpp" +#include "ObjImpls/CKObject.hpp" #include "../VxMath/VxMemoryMappedFile.hpp" #include "CKContext.hpp" #include @@ -190,8 +190,7 @@ namespace LibCmo::CK2 { } CKERROR CKFileReader::ReadFileData(CKBufferParser* ParserPtr) { - std::unique_ptr parser(new(std::nothrow) CKBufferParser(ParserPtr->GetBase(), ParserPtr->GetSize(), false)); - if (parser == nullptr) return CKERROR::CKERR_OUTOFMEMORY; + std::unique_ptr parser(new CKBufferParser(ParserPtr->GetBase(), ParserPtr->GetSize(), false)); parser->SetCursor(ParserPtr->GetCursor()); std::string name_conv; @@ -290,7 +289,7 @@ namespace LibCmo::CK2 { // ========== included file get ========== // before reading, we need switch back to original parser. // and skip data chunk size - parser = std::unique_ptr(new(std::nothrow) CKBufferParser(ParserPtr->GetBase(), ParserPtr->GetSize(), false)); + parser = std::unique_ptr(new CKBufferParser(ParserPtr->GetBase(), ParserPtr->GetSize(), false)); parser->MoveCursor(this->m_FileInfo.DataPackSize); // then we can read it. diff --git a/LibCmo/CK2/CKGlobals.cpp b/LibCmo/CK2/CKGlobals.cpp index dead4b3..7086e49 100644 --- a/LibCmo/CK2/CKGlobals.cpp +++ b/LibCmo/CK2/CKGlobals.cpp @@ -10,7 +10,7 @@ #include #include -#include "CKObjectImplements/CKObject.hpp" +#include "ObjImpls/CKObject.hpp" namespace LibCmo::CK2 { @@ -191,8 +191,8 @@ namespace LibCmo::CK2 { CKERROR CKStartUp() { // todo: add class type registrations CKClassRegister(CK_CLASSID::CKCID_OBJECT, CK_CLASSID::CKCID_OBJECT, - [](CKContext* ctx, CK_ID id, CKSTRING name) -> CKObject* { return new CKObject(ctx, id, name); }, - [](CKContext* ctx, CKObject* obj) -> void { delete obj; }, + [](CKContext* ctx, CK_ID id, CKSTRING name) -> ObjImpls::CKObject* { return new ObjImpls::CKObject(ctx, id, name); }, + [](CKContext* ctx, ObjImpls::CKObject* obj) -> void { delete obj; }, []() -> CKSTRING { return "Basic Object"; }); /* diff --git a/LibCmo/CK2/CKStateChunk.cpp b/LibCmo/CK2/CKStateChunk.cpp index 040e14e..a156b55 100644 --- a/LibCmo/CK2/CKStateChunk.cpp +++ b/LibCmo/CK2/CKStateChunk.cpp @@ -18,7 +18,7 @@ namespace LibCmo::CK2 { CKStateChunk::CKStateChunk(CKFileVisitor* visitor, CKContext* ctx) : m_ClassId(CK_CLASSID::CKCID_OBJECT), m_DataDwSize(0u), m_pData(nullptr), m_DataVersion(CK_STATECHUNK_DATAVERSION::CHUNKDATA_CURRENTVERSION), m_ChunkVersion(CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION4), - m_Parser{ CKStateChunkStatus::IDLE, 0u, 0u, 0u }, + m_Parser { CKStateChunkStatus::IDLE, 0u, 0u, 0u }, m_ObjectList(), m_ChunkList(), m_ManagerList(), m_BindFile(visitor), m_BindContext(ctx) {} @@ -31,13 +31,23 @@ namespace LibCmo::CK2 { m_BindFile(rhs.m_BindFile), m_BindContext(rhs.m_BindContext) { // copy buffer if (rhs.m_pData != nullptr) { - this->m_pData = new(std::nothrow) CKDWORD[rhs.m_DataDwSize]; - if (this->m_pData != nullptr) { + this->m_pData = new CKDWORD[rhs.m_DataDwSize]; std::memcpy(this->m_pData, rhs.m_pData, sizeof(CKDWORD) * rhs.m_DataDwSize); - } } } + CKStateChunk::CKStateChunk(CKStateChunk&& rhs) : + m_ClassId(rhs.m_ClassId), m_DataVersion(rhs.m_DataVersion), m_ChunkVersion(rhs.m_ChunkVersion), + m_Parser(rhs.m_Parser), + m_ObjectList(std::move(rhs.m_ObjectList)), m_ManagerList(std::move(rhs.m_ManagerList)), m_ChunkList(std::move(rhs.m_ChunkList)), + m_pData(rhs.m_pData), m_DataDwSize(rhs.m_DataDwSize), + m_BindFile(rhs.m_BindFile), m_BindContext(rhs.m_BindContext) { + // set to null after steal data + rhs.m_pData = nullptr; + // and clear it + rhs.Clear(); + } + CKStateChunk& CKStateChunk::operator=(const CKStateChunk& rhs) { this->Clear(); @@ -56,15 +66,41 @@ namespace LibCmo::CK2 { // copy buffer if (rhs.m_pData != nullptr) { - this->m_pData = new(std::nothrow) CKDWORD[rhs.m_DataDwSize]; - if (this->m_pData != nullptr) { + this->m_pData = new CKDWORD[rhs.m_DataDwSize]; std::memcpy(this->m_pData, rhs.m_pData, sizeof(CKDWORD) * rhs.m_DataDwSize); - } } this->m_DataDwSize = rhs.m_DataDwSize; return *this; } + + CKStateChunk& CKStateChunk::operator=(CKStateChunk&& rhs) { + this->Clear(); + + this->m_DataVersion = rhs.m_DataVersion; + this->m_ChunkVersion = rhs.m_ChunkVersion; + this->m_ClassId = rhs.m_ClassId; + + this->m_Parser = rhs.m_Parser; + + this->m_ObjectList = rhs.m_ObjectList; + this->m_ManagerList = rhs.m_ManagerList; + this->m_ChunkList = rhs.m_ChunkList; + + this->m_BindFile = rhs.m_BindFile; + this->m_BindContext = rhs.m_BindContext; + + // steal buffer + this->m_pData = rhs.m_pData; + rhs.m_pData = nullptr; + this->m_DataDwSize = rhs.m_DataDwSize; + + // clear steal chunk + rhs.Clear(); + + return *this; + } + CKStateChunk::~CKStateChunk() { if (this->m_pData != nullptr) delete[] this->m_pData; @@ -79,6 +115,7 @@ namespace LibCmo::CK2 { this->m_DataVersion = CK_STATECHUNK_DATAVERSION::CHUNK_DEV_2_1; this->m_ChunkVersion = CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION4; + this->m_Parser.m_Status = CKStateChunkStatus::IDLE; this->m_Parser.m_CurrentPos = 0; this->m_Parser.m_DataSize = 0; this->m_Parser.m_PrevIdentifierPos = 0; @@ -148,8 +185,7 @@ namespace LibCmo::CK2 { } } else { // otherwise, we create a new buffer instead it - CKDWORD* newbuf = new(std::nothrow) CKDWORD[new_dwsize]; - if (newbuf == nullptr) return false; // if fail to create, return + CKDWORD* newbuf = new CKDWORD[new_dwsize]; // if no original data, we do not need copy it and free it if (this->m_pData != nullptr) { @@ -221,9 +257,7 @@ namespace LibCmo::CK2 { bufpos = 6u; if (this->m_DataDwSize != 0) { - this->m_pData = new(std::nothrow) CKDWORD[this->m_DataDwSize]; - if (m_pData == nullptr) return false; - + this->m_pData = new CKDWORD[this->m_DataDwSize]; std::memcpy(this->m_pData, dwbuf + bufpos, sizeof(CKDWORD) * this->m_DataDwSize); bufpos += this->m_DataDwSize; } @@ -248,9 +282,7 @@ namespace LibCmo::CK2 { bufpos = 7u; if (this->m_DataDwSize != 0) { - this->m_pData = new(std::nothrow) CKDWORD[this->m_DataDwSize]; - if (m_pData == nullptr) return false; - + this->m_pData = new CKDWORD[this->m_DataDwSize]; std::memcpy(this->m_pData, dwbuf + bufpos, sizeof(CKDWORD) * this->m_DataDwSize); bufpos += this->m_DataDwSize; } @@ -285,9 +317,7 @@ namespace LibCmo::CK2 { bufpos = 2u; if (this->m_DataDwSize != 0) { - this->m_pData = new(std::nothrow) CKDWORD[this->m_DataDwSize]; - if (m_pData == nullptr) return false; - + this->m_pData = new CKDWORD[this->m_DataDwSize]; std::memcpy(this->m_pData, dwbuf + bufpos, sizeof(CKDWORD) * this->m_DataDwSize); bufpos += this->m_DataDwSize; } @@ -335,8 +365,7 @@ namespace LibCmo::CK2 { // // dwSize store the length of compressed buffer as CHAR size, not DWORD size! // // create a enough buffer - // char* buffer = new(std::nothrow) char[DestSize]; - // if (buffer == nullptr) return false; + // char* buffer = new char[DestSize]; // uLongf destSize = DestSize; // // uncompress it // auto err = uncompress( @@ -350,10 +379,8 @@ namespace LibCmo::CK2 { // delete[] this->m_pData; // this->m_pData = nullptr; - // this->m_pData = new(std::nothrow) CKDWORD[this->m_DataDwSize]; - // if (this->m_pData != nullptr) { + // this->m_pData = new CKDWORD[this->m_DataDwSize]; // std::memcpy(this->m_pData, buffer, this->m_DataDwSize * sizeof(CKDWORD)); - // } // } // delete[] buffer; // return true; @@ -509,8 +536,7 @@ namespace LibCmo::CK2 { if (!this->EnsureReadSpace(subChunkSize)) goto subchunk_defer; // create statechunk - subchunk = new(std::nothrow) CKStateChunk(this->m_BindFile, this->m_BindContext); - if (subchunk == nullptr) goto subchunk_defer; + subchunk = new CKStateChunk(this->m_BindFile, this->m_BindContext); // start read data // read class id @@ -528,8 +554,7 @@ namespace LibCmo::CK2 { // read data size and create it if (!this->ReadStruct(subchunk->m_DataDwSize)) goto subchunk_defer; - subchunk->m_pData = new(std::nothrow) CKDWORD[subchunk->m_DataDwSize]; - if (subchunk->m_pData == nullptr) goto subchunk_defer; + subchunk->m_pData = new CKDWORD[subchunk->m_DataDwSize]; // has bind file? CKDWORD hasBindFile; @@ -578,8 +603,7 @@ namespace LibCmo::CK2 { // read data size and create it if (!this->ReadStruct(subchunk->m_DataDwSize)) goto subchunk_defer; - subchunk->m_pData = new(std::nothrow) CKDWORD[subchunk->m_DataDwSize]; - if (subchunk->m_pData == nullptr) goto subchunk_defer; + subchunk->m_pData = new CKDWORD[subchunk->m_DataDwSize]; // skip one? // I don't know why @@ -616,11 +640,7 @@ namespace LibCmo::CK2 { *len_in_byte = bufByteSize; // create buffer - *buf = new(std::nothrow) char[bufByteSize]; - if (*buf == nullptr) { - *len_in_byte = 0; - return false; - } + *buf = new char[bufByteSize]; // read data if (!this->ReadByteData(*buf, bufByteSize)) { @@ -718,7 +738,7 @@ namespace LibCmo::CK2 { CKDWORD count; if (!this->ReadStruct(count)) return false; if (!count) return true; // 0 size array - + // old file size correction if (this->m_ChunkVersion < CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION1) { // skip 4. but I don't know why!!! diff --git a/LibCmo/CK2/CKStateChunk.hpp b/LibCmo/CK2/CKStateChunk.hpp index edd22c0..54ea423 100644 --- a/LibCmo/CK2/CKStateChunk.hpp +++ b/LibCmo/CK2/CKStateChunk.hpp @@ -11,7 +11,7 @@ namespace LibCmo::CK2 { CKStateChunk(const CKStateChunk&); CKStateChunk(CKStateChunk&&); CKStateChunk& operator=(const CKStateChunk&); - CKStateChunk& operator-(const CKStateChunk&&); + CKStateChunk& operator=(CKStateChunk&&); ~CKStateChunk(); private: @@ -20,6 +20,12 @@ namespace LibCmo::CK2 { READ, WRITE }; + struct ChunkParser { + CKStateChunkStatus m_Status; + CKDWORD m_CurrentPos; + CKDWORD m_DataSize; + CKDWORD m_PrevIdentifierPos; + }; CK_CLASSID m_ClassId; CKDWORD m_DataDwSize; @@ -28,12 +34,7 @@ namespace LibCmo::CK2 { CK_STATECHUNK_DATAVERSION m_DataVersion; CK_STATECHUNK_CHUNKVERSION m_ChunkVersion; - struct { - CKStateChunkStatus m_Status; - CKDWORD m_CurrentPos; - CKDWORD m_DataSize; - CKDWORD m_PrevIdentifierPos; - }m_Parser; + ChunkParser m_Parser; std::vector m_ObjectList; std::vector m_ChunkList; diff --git a/LibCmo/CK2/CKTypes.hpp b/LibCmo/CK2/CKTypes.hpp index 9ced99a..11b2d89 100644 --- a/LibCmo/CK2/CKTypes.hpp +++ b/LibCmo/CK2/CKTypes.hpp @@ -191,87 +191,91 @@ namespace LibCmo::CK2 { // ========== Class List ========== // Objects and derivated classes - class CKObject; - class CKInterfaceObjectManager; - class CKRenderContext; - class CKParameterIn; - class CKParameter; - class CKParameterOut; - class CKParameterLocal; - class CKParameterOperation; - class CKBehaviorLink; - class CKBehaviorIO; - class CKRenderContext; - class CKSynchroObject; - class CKStateObject; - class CKCriticalSectionObject; - class CKKinematicChain; - class CKObjectAnimation; - class CKLayer; - class CKSceneObject; - class CKBehavior; - class CKAnimation; - class CKKeyedAnimation; - class CKBeObject; - class CKScene; - class CKLevel; - class CKPlace; - class CKGroup; - class CKMaterial; - class CKTexture; - class CKMesh; - class CKPatchMesh; - class CKProgressiveMesh; - class CKDataArray; - class CKSound; - class CKMidiSound; - class CKWaveSound; - class CKRenderObject; - class CK2dEntity; - class CKSprite; - class CKSpriteText; - class CK3dEntity; - class CKCamera; - class CKTargetCamera; - class CKCurvePoint; - class CKSprite3D; - class CKLight; - class CKTargetLight; - class CKCharacter; - class CK3dObject; - class CKBodyPart; - class CKCurve; - class CKGrid; + namespace ObjImpls { + class CKObject; + class CKInterfaceObjectManager; + class CKRenderContext; + class CKParameterIn; + class CKParameter; + class CKParameterOut; + class CKParameterLocal; + class CKParameterOperation; + class CKBehaviorLink; + class CKBehaviorIO; + class CKRenderContext; + class CKSynchroObject; + class CKStateObject; + class CKCriticalSectionObject; + class CKKinematicChain; + class CKObjectAnimation; + class CKLayer; + class CKSceneObject; + class CKBehavior; + class CKAnimation; + class CKKeyedAnimation; + class CKBeObject; + class CKScene; + class CKLevel; + class CKPlace; + class CKGroup; + class CKMaterial; + class CKTexture; + class CKMesh; + class CKPatchMesh; + class CKProgressiveMesh; + class CKDataArray; + class CKSound; + class CKMidiSound; + class CKWaveSound; + class CKRenderObject; + class CK2dEntity; + class CKSprite; + class CKSpriteText; + class CK3dEntity; + class CKCamera; + class CKTargetCamera; + class CKCurvePoint; + class CKSprite3D; + class CKLight; + class CKTargetLight; + class CKCharacter; + class CK3dObject; + class CKBodyPart; + class CKCurve; + class CKGrid; + } //---- Misc class CKBehaviorPrototype; class CKMessage; class CK2dCurvePoint; class CK2dCurve; - class CKStateChunk; - class CKFile; + //class CKStateChunk; + //class CKFile; class CKDependencies; class CKDependenciesContext; class CKPluginManager; class CKDebugContext; class CKObjectArray; class CKObjectDeclaration; - class CKContext; + //class CKContext; struct CKBitmapProperties; class CKVertexBuffer; //--- Managers - class CKBaseManager; - class CKSoundManager; - class CKTimeManager; - class CKRenderManager; - class CKBehaviorManager; - class CKMessageManager; - class CKParameterManager; - class CKAttributeManager; - class CKPathManager; - class CKVariableManager; - class CKSceneObjectDesc; + namespace MgrImpls { + class CKBaseManager; + class CKSoundManager; + class CKTimeManager; + class CKRenderManager; + class CKBehaviorManager; + class CKMessageManager; + class CKParameterManager; + class CKAttributeManager; + class CKPathManager; + class CKVariableManager; + class CKSceneObjectDesc; + } //--- Important classes class CKContext; diff --git a/LibCmo/CK2/CKManagerImplements/CKBaseManager.cpp b/LibCmo/CK2/MgrImpls/CKBaseManager.cpp similarity index 93% rename from LibCmo/CK2/CKManagerImplements/CKBaseManager.cpp rename to LibCmo/CK2/MgrImpls/CKBaseManager.cpp index 88b55ad..492be93 100644 --- a/LibCmo/CK2/CKManagerImplements/CKBaseManager.cpp +++ b/LibCmo/CK2/MgrImpls/CKBaseManager.cpp @@ -1,6 +1,6 @@ #include "CKBaseManager.hpp" -namespace LibCmo::CK2 { +namespace LibCmo::CK2::MgrImpls { // todo: this file maybe not used anymore. if more manager added. i think this file can be removed. //CKERROR CKBaseManager::LoadData(CKStateChunk* statechunk, CKFileDocument* doc) { diff --git a/LibCmo/CK2/CKManagerImplements/CKBaseManager.hpp b/LibCmo/CK2/MgrImpls/CKBaseManager.hpp similarity index 99% rename from LibCmo/CK2/CKManagerImplements/CKBaseManager.hpp rename to LibCmo/CK2/MgrImpls/CKBaseManager.hpp index da93fcd..7592ba5 100644 --- a/LibCmo/CK2/CKManagerImplements/CKBaseManager.hpp +++ b/LibCmo/CK2/MgrImpls/CKBaseManager.hpp @@ -2,7 +2,7 @@ #include "../../VTAll.hpp" -namespace LibCmo::CK2 { +namespace LibCmo::CK2::MgrImpls { /** @brief Base Class for managers. diff --git a/LibCmo/CK2/CKObjectImplements/CKObject.cpp b/LibCmo/CK2/ObjImpls/CKObject.cpp similarity index 99% rename from LibCmo/CK2/CKObjectImplements/CKObject.cpp rename to LibCmo/CK2/ObjImpls/CKObject.cpp index fc4ce6d..d5751aa 100644 --- a/LibCmo/CK2/CKObjectImplements/CKObject.cpp +++ b/LibCmo/CK2/ObjImpls/CKObject.cpp @@ -1,7 +1,7 @@ #include "CKObject.hpp" #include "../CKStateChunk.hpp" -namespace LibCmo::CK2 { +namespace LibCmo::CK2::ObjImpls { void CKObject::PreSave(CKFileVisitor* file, CKDWORD flags) {} diff --git a/LibCmo/CK2/CKObjectImplements/CKObject.hpp b/LibCmo/CK2/ObjImpls/CKObject.hpp similarity index 99% rename from LibCmo/CK2/CKObjectImplements/CKObject.hpp rename to LibCmo/CK2/ObjImpls/CKObject.hpp index d6f31fe..4b3985d 100644 --- a/LibCmo/CK2/CKObjectImplements/CKObject.hpp +++ b/LibCmo/CK2/ObjImpls/CKObject.hpp @@ -3,7 +3,7 @@ #include "../../VTUtils.hpp" #include "../CKContext.hpp" -namespace LibCmo::CK2 { +namespace LibCmo::CK2::ObjImpls { class CKObject { public: diff --git a/LibCmo/LibCmo.vcxproj b/LibCmo/LibCmo.vcxproj index e239559..7dd11d7 100644 --- a/LibCmo/LibCmo.vcxproj +++ b/LibCmo/LibCmo.vcxproj @@ -178,9 +178,9 @@ - + - + @@ -193,13 +193,13 @@ - + - + diff --git a/LibCmo/LibCmo.vcxproj.filters b/LibCmo/LibCmo.vcxproj.filters index 8a08ccb..3e36177 100644 --- a/LibCmo/LibCmo.vcxproj.filters +++ b/LibCmo/LibCmo.vcxproj.filters @@ -31,16 +31,16 @@ {3dee80b5-d27a-4071-9194-3c817ba38c4c} - + {bc2c80b7-8622-41f4-9bef-480a71430eb8} - + {9bec41df-78db-4753-ab80-86345545227d} - + {784282d9-4adb-40ca-bbac-902c74e9a2e5} - + {a8cd2188-b552-478c-9801-a6286b3d48a0} @@ -48,14 +48,14 @@ Sources - - Sources\CK2\CKObjectImplements + + Sources\CK2\ObjImpls Sources - - Sources\CK2\CKManagerImplements + + Sources\CK2\MgrImpls Sources\VxMath @@ -122,11 +122,11 @@ Headers - - Headers\CK2\CKObjectImplements + + Headers\CK2\ObjImpls - - Headers\CK2\CKManagerImplements + + Headers\CK2\MgrImpls \ No newline at end of file diff --git a/LibCmo/VTEncoding.cpp b/LibCmo/VTEncoding.cpp index 504b759..10e7b97 100644 --- a/LibCmo/VTEncoding.cpp +++ b/LibCmo/VTEncoding.cpp @@ -156,9 +156,7 @@ namespace LibCmo::EncodingHelper { #if defined(LIBCMO_OS_WIN32) ENCODING_TOKEN CreateEncodingToken(const std::string& token_string) { - ENCODING_TOKEN token = new(std::nothrow) UINT(); - if (token == nullptr) return ENCODING_TOKEN_DEFAULT; - + ENCODING_TOKEN token = new UINT(); if (!GetWindowsCodePage(token_string.c_str(), token)) { *token = CP_ACP; } @@ -209,9 +207,7 @@ namespace LibCmo::EncodingHelper { static constexpr const char UTF8_SYMBOL[] = "UTF-8"; ENCODING_TOKEN CreateEncodingToken(const std::string& token_string) { - ENCODING_TOKEN token = new(std::nothrow) IconvPair(); - if (token == nullptr) return ENCODING_TOKEN_DEFAULT; - + ENCODING_TOKEN token = new IconvPair(); if (!CreateIconvDescriptor(UTF8_SYMBOL, token_string.c_str(), token->FromUtf8) || !CreateIconvDescriptor(token_string.c_str(), UTF8_SYMBOL, token->ToUtf8)) { delete token; diff --git a/LibCmo/XContainer/XTypes.hpp b/LibCmo/XContainer/XTypes.hpp index a32619a..e2e0d2b 100644 --- a/LibCmo/XContainer/XTypes.hpp +++ b/LibCmo/XContainer/XTypes.hpp @@ -55,7 +55,7 @@ namespace LibCmo::XContainer { @todo May independ this class to implement the functions introduced in remarks. @see XObjectArray, CKObjectArray */ - using XObjectPointerArray = XArray; + using XObjectPointerArray = XArray; /** @brief Class representation of an Hash Table container.