remove all std::nothrow and re-create namespace for objs and mgrs
This commit is contained in:
		| @ -1,5 +1,5 @@ | ||||
| #include "CKContext.hpp" | ||||
| #include "CKObjectImplements/CKObject.hpp" | ||||
| #include "ObjImpls/CKObject.hpp" | ||||
| #include <cstdarg> | ||||
|  | ||||
| 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 | ||||
|  | ||||
| @ -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<CKObject*> m_ObjectsList; | ||||
| 		XContainer::XArray<ObjImpls::CKObject*> m_ObjectsList; | ||||
| 		std::deque<CK_ID> m_ReturnedObjectIds; | ||||
|  | ||||
| 		// ========== Encoding utilities ========== | ||||
|  | ||||
| @ -22,8 +22,8 @@ namespace LibCmo::CK2 { | ||||
| 	// ========== Class registration utilities ========== | ||||
|  | ||||
| 	//using CKClassRegisterFct = std::function<void()>; | ||||
| 	using CKClassCreationFct = std::function<CKObject* (CKContext*, CK_ID, CKSTRING)>; | ||||
| 	using CKClassReleaseFct = std::function<void(CKContext*, CKObject*)>; | ||||
| 	using CKClassCreationFct = std::function<ObjImpls::CKObject* (CKContext*, CK_ID, CKSTRING)>; | ||||
| 	using CKClassReleaseFct = std::function<void(CKContext*, ObjImpls::CKObject*)>; | ||||
| 	using CKClassNameFct = std::function<CKSTRING()>; | ||||
| 	//using CKClassDependenciesFct = std::function<CKSTRING(CKINT, CKINT)>; | ||||
| 	//using CKClassDependenciesCountFct = std::function<CKINT(CKINT)>; | ||||
| @ -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); | ||||
| 	}; | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
|  | ||||
| @ -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; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| @ -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 <memory> | ||||
| @ -190,8 +190,7 @@ namespace LibCmo::CK2 { | ||||
| 	} | ||||
|  | ||||
| 	CKERROR CKFileReader::ReadFileData(CKBufferParser* ParserPtr) { | ||||
| 		std::unique_ptr<CKBufferParser> parser(new(std::nothrow) CKBufferParser(ParserPtr->GetBase(), ParserPtr->GetSize(), false)); | ||||
| 		if (parser == nullptr) return CKERROR::CKERR_OUTOFMEMORY; | ||||
| 		std::unique_ptr<CKBufferParser> 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<CKBufferParser>(new(std::nothrow) CKBufferParser(ParserPtr->GetBase(), ParserPtr->GetSize(), false)); | ||||
| 		parser = std::unique_ptr<CKBufferParser>(new CKBufferParser(ParserPtr->GetBase(), ParserPtr->GetSize(), false)); | ||||
| 		parser->MoveCursor(this->m_FileInfo.DataPackSize); | ||||
|  | ||||
| 		// then we can read it. | ||||
|  | ||||
| @ -10,7 +10,7 @@ | ||||
| #include <algorithm> | ||||
| #include <zlib.h> | ||||
|  | ||||
| #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"; }); | ||||
|  | ||||
| 		/* | ||||
|  | ||||
| @ -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!!! | ||||
|  | ||||
| @ -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<CKDWORD> m_ObjectList; | ||||
| 		std::vector<CKDWORD> m_ChunkList; | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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) {
 | ||||
| @ -2,7 +2,7 @@ | ||||
| 
 | ||||
| #include "../../VTAll.hpp" | ||||
| 
 | ||||
| namespace LibCmo::CK2 { | ||||
| namespace LibCmo::CK2::MgrImpls { | ||||
| 
 | ||||
| 	/**
 | ||||
| 	@brief Base Class for managers. | ||||
| @ -1,7 +1,7 @@ | ||||
| #include "CKObject.hpp" | ||||
| #include "../CKStateChunk.hpp" | ||||
| 
 | ||||
| namespace LibCmo::CK2 { | ||||
| namespace LibCmo::CK2::ObjImpls { | ||||
| 
 | ||||
| 
 | ||||
| 	void CKObject::PreSave(CKFileVisitor* file, CKDWORD flags) {} | ||||
| @ -3,7 +3,7 @@ | ||||
| #include "../../VTUtils.hpp" | ||||
| #include "../CKContext.hpp" | ||||
| 
 | ||||
| namespace LibCmo::CK2 { | ||||
| namespace LibCmo::CK2::ObjImpls { | ||||
| 
 | ||||
| 	class CKObject { | ||||
| 	public: | ||||
| @ -178,9 +178,9 @@ | ||||
|     <ClCompile Include="CK2\CKFileOthers.cpp" /> | ||||
|     <ClCompile Include="CK2\CKFileWriter.cpp" /> | ||||
|     <ClCompile Include="CK2\CKGlobals.cpp" /> | ||||
|     <ClCompile Include="CK2\CKManagerImplements\CKBaseManager.cpp" /> | ||||
|     <ClCompile Include="CK2\MgrImpls\CKBaseManager.cpp" /> | ||||
|     <ClCompile Include="CK2\CKContext.cpp" /> | ||||
|     <ClCompile Include="CK2\CKObjectImplements\CKObject.cpp" /> | ||||
|     <ClCompile Include="CK2\ObjImpls\CKObject.cpp" /> | ||||
|     <ClCompile Include="VTEncoding.cpp" /> | ||||
|     <ClCompile Include="CK2\CKFileReader.cpp" /> | ||||
|     <ClCompile Include="CK2\CKStateChunk.cpp" /> | ||||
| @ -193,13 +193,13 @@ | ||||
|     <ClInclude Include="CK2\CKFile.hpp" /> | ||||
|     <ClInclude Include="CK2\CKGlobals.hpp" /> | ||||
|     <ClInclude Include="CK2\CKIdentifiers.hpp" /> | ||||
|     <ClInclude Include="CK2\CKManagerImplements\CKBaseManager.hpp" /> | ||||
|     <ClInclude Include="CK2\MgrImpls\CKBaseManager.hpp" /> | ||||
|     <ClInclude Include="CK2\CKContext.hpp" /> | ||||
|     <ClInclude Include="CK2\CKStateChunk.hpp" /> | ||||
|     <ClInclude Include="CK2\CKTypes.hpp" /> | ||||
|     <ClInclude Include="VTAll.hpp" /> | ||||
|     <ClInclude Include="VTEncoding.hpp" /> | ||||
|     <ClInclude Include="CK2\CKObjectImplements\CKObject.hpp" /> | ||||
|     <ClInclude Include="CK2\ObjImpls\CKObject.hpp" /> | ||||
|     <ClInclude Include="VTUtils.hpp" /> | ||||
|     <ClInclude Include="VxMath\VxMemoryMappedFile.hpp" /> | ||||
|     <ClInclude Include="VxMath\VxTypes.hpp" /> | ||||
|  | ||||
| @ -31,16 +31,16 @@ | ||||
|     <Filter Include="Sources\XContainer"> | ||||
|       <UniqueIdentifier>{3dee80b5-d27a-4071-9194-3c817ba38c4c}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|     <Filter Include="Headers\CK2\CKManagerImplements"> | ||||
|     <Filter Include="Headers\CK2\MgrImpls"> | ||||
|       <UniqueIdentifier>{bc2c80b7-8622-41f4-9bef-480a71430eb8}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|     <Filter Include="Headers\CK2\CKObjectImplements"> | ||||
|     <Filter Include="Headers\CK2\ObjImpls"> | ||||
|       <UniqueIdentifier>{9bec41df-78db-4753-ab80-86345545227d}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|     <Filter Include="Sources\CK2\CKManagerImplements"> | ||||
|     <Filter Include="Sources\CK2\MgrImpls"> | ||||
|       <UniqueIdentifier>{784282d9-4adb-40ca-bbac-902c74e9a2e5}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|     <Filter Include="Sources\CK2\CKObjectImplements"> | ||||
|     <Filter Include="Sources\CK2\ObjImpls"> | ||||
|       <UniqueIdentifier>{a8cd2188-b552-478c-9801-a6286b3d48a0}</UniqueIdentifier> | ||||
|     </Filter> | ||||
|   </ItemGroup> | ||||
| @ -48,14 +48,14 @@ | ||||
|     <ClCompile Include="VTEncoding.cpp"> | ||||
|       <Filter>Sources</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="CK2\CKObjectImplements\CKObject.cpp"> | ||||
|       <Filter>Sources\CK2\CKObjectImplements</Filter> | ||||
|     <ClCompile Include="CK2\ObjImpls\CKObject.cpp"> | ||||
|       <Filter>Sources\CK2\ObjImpls</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="VTUtils.cpp"> | ||||
|       <Filter>Sources</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="CK2\CKManagerImplements\CKBaseManager.cpp"> | ||||
|       <Filter>Sources\CK2\CKManagerImplements</Filter> | ||||
|     <ClCompile Include="CK2\MgrImpls\CKBaseManager.cpp"> | ||||
|       <Filter>Sources\CK2\MgrImpls</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="VxMath\VxMemoryMappedFile.cpp"> | ||||
|       <Filter>Sources\VxMath</Filter> | ||||
| @ -122,11 +122,11 @@ | ||||
|     <ClInclude Include="VTAll.hpp"> | ||||
|       <Filter>Headers</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="CK2\CKManagerImplements\CKBaseManager.hpp"> | ||||
|       <Filter>Headers\CK2\CKObjectImplements</Filter> | ||||
|     <ClInclude Include="CK2\MgrImpls\CKBaseManager.hpp"> | ||||
|       <Filter>Headers\CK2\ObjImpls</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="CK2\CKObjectImplements\CKObject.hpp"> | ||||
|       <Filter>Headers\CK2\CKManagerImplements</Filter> | ||||
|     <ClInclude Include="CK2\ObjImpls\CKObject.hpp"> | ||||
|       <Filter>Headers\CK2\MgrImpls</Filter> | ||||
|     </ClInclude> | ||||
|   </ItemGroup> | ||||
| </Project> | ||||
| @ -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; | ||||
|  | ||||
| @ -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<CK2::CKObject*>; | ||||
| 	using XObjectPointerArray = XArray<CK2::ObjImpls::CKObject*>; | ||||
|  | ||||
| 	/** | ||||
| 	@brief Class representation of an Hash Table container. | ||||
|  | ||||
		Reference in New Issue
	
	Block a user