fix compile error by split some classes into CKStructs.hpp. ready for CKBitmapData
This commit is contained in:
parent
54a3dd7776
commit
138e47cbdc
9
LibCmo/CK2/CKBitmapData.cpp
Normal file
9
LibCmo/CK2/CKBitmapData.cpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#include "CKBitmapData.hpp"
|
||||||
|
|
||||||
|
namespace LibCmo::CK2 {
|
||||||
|
|
||||||
|
CKBitmapData::CKBitmapData() {}
|
||||||
|
|
||||||
|
CKBitmapData::~CKBitmapData() {}
|
||||||
|
|
||||||
|
}
|
16
LibCmo/CK2/CKBitmapData.hpp
Normal file
16
LibCmo/CK2/CKBitmapData.hpp
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../VTAll.hpp"
|
||||||
|
|
||||||
|
namespace LibCmo::CK2 {
|
||||||
|
|
||||||
|
class CKBitmapData {
|
||||||
|
public:
|
||||||
|
CKBitmapData();
|
||||||
|
~CKBitmapData();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
79
LibCmo/CK2/CKStructs.hpp
Normal file
79
LibCmo/CK2/CKStructs.hpp
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CKGlobals.hpp"
|
||||||
|
|
||||||
|
namespace LibCmo::CK2 {
|
||||||
|
|
||||||
|
// a stupid forward decl to remove something
|
||||||
|
/**
|
||||||
|
* @brief Storage class for filename extensions
|
||||||
|
*/
|
||||||
|
class CKFileExtension {
|
||||||
|
public:
|
||||||
|
CKFileExtension() : m_Data() {
|
||||||
|
std::memset(m_Data, 0, c_DataLen);
|
||||||
|
}
|
||||||
|
CKFileExtension(CKSTRING s) : CKFileExtension() {
|
||||||
|
SetExt(s);
|
||||||
|
}
|
||||||
|
CKFileExtension(const CKFileExtension& rhs) : CKFileExtension() {
|
||||||
|
std::memcpy(m_Data, rhs.m_Data, c_DataLen);
|
||||||
|
}
|
||||||
|
CKFileExtension(CKFileExtension&& rhs) : CKFileExtension() {
|
||||||
|
std::memmove(m_Data, rhs.m_Data, c_DataLen);
|
||||||
|
std::memset(rhs.m_Data, 0, c_DataLen);
|
||||||
|
}
|
||||||
|
CKFileExtension& operator=(const CKFileExtension& rhs) {
|
||||||
|
std::memcpy(m_Data, rhs.m_Data, c_DataLen);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
CKFileExtension& operator=(CKFileExtension&& rhs) {
|
||||||
|
std::memmove(m_Data, rhs.m_Data, c_DataLen);
|
||||||
|
std::memset(rhs.m_Data, 0, c_DataLen);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetExt(CKSTRING s) {
|
||||||
|
if (s == nullptr) {
|
||||||
|
m_Data[0] = '\0';
|
||||||
|
} else {
|
||||||
|
if (s[0] == '.') ++s; // skip dot
|
||||||
|
size_t len = std::strlen(s);
|
||||||
|
if (len > (c_DataLen - 1)) len = c_DataLen - 1;
|
||||||
|
std::memcpy(m_Data, s, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CKSTRING GetExt() const {
|
||||||
|
return m_Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const CKFileExtension& rhs) const {
|
||||||
|
return CKStrEqualI(m_Data, rhs.m_Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static const size_t c_DataLen = 4u;
|
||||||
|
CKCHAR m_Data[c_DataLen];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The struct describe the bitmap handler's infomation,
|
||||||
|
* including its GUID and supported file extension.
|
||||||
|
* This struct also will store some parameters related to bitmap handler,
|
||||||
|
* such as jpeg compress level and etc. But currently there are no
|
||||||
|
* such parameters.
|
||||||
|
*/
|
||||||
|
class CKBitmapProperties {
|
||||||
|
public:
|
||||||
|
CKBitmapProperties() :
|
||||||
|
m_ReaderGuid(), m_Ext() {}
|
||||||
|
CKBitmapProperties(const CKGUID& guid, CKSTRING ext) :
|
||||||
|
m_ReaderGuid(guid), m_Ext(ext) {}
|
||||||
|
LIBCMO_DEFAULT_COPY_MOVE(CKBitmapProperties);
|
||||||
|
|
||||||
|
CKGUID m_ReaderGuid; /**< CKGUID that uniquely identifies the reader that created this properties structure */
|
||||||
|
CKFileExtension m_Ext; /**< File Extension of the image being described by this structure */
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -266,7 +266,8 @@ namespace LibCmo::CK2 {
|
||||||
class CKObjectArray;
|
class CKObjectArray;
|
||||||
class CKObjectDeclaration;
|
class CKObjectDeclaration;
|
||||||
//class CKContext;
|
//class CKContext;
|
||||||
//struct CKBitmapProperties;
|
class CKBitmapProperties;
|
||||||
|
class CKFileExtension;
|
||||||
class CKVertexBuffer;
|
class CKVertexBuffer;
|
||||||
|
|
||||||
//--- Managers
|
//--- Managers
|
||||||
|
@ -366,74 +367,4 @@ namespace LibCmo::CK2 {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Storage class for filename extensions
|
|
||||||
*/
|
|
||||||
class CKFileExtension {
|
|
||||||
public:
|
|
||||||
CKFileExtension() : m_Data() {
|
|
||||||
std::memset(m_Data, 0, c_DataLen);
|
|
||||||
}
|
|
||||||
CKFileExtension(CKSTRING s) : CKFileExtension() {
|
|
||||||
SetExt(s);
|
|
||||||
}
|
|
||||||
CKFileExtension(const CKFileExtension& rhs) : CKFileExtension() {
|
|
||||||
std::memcpy(m_Data, rhs.m_Data, c_DataLen);
|
|
||||||
}
|
|
||||||
CKFileExtension(CKFileExtension&& rhs) : CKFileExtension() {
|
|
||||||
std::memmove(m_Data, rhs.m_Data, c_DataLen);
|
|
||||||
std::memset(rhs.m_Data, 0, c_DataLen);
|
|
||||||
}
|
|
||||||
CKFileExtension& operator=(const CKFileExtension& rhs) {
|
|
||||||
std::memcpy(m_Data, rhs.m_Data, c_DataLen);
|
|
||||||
}
|
|
||||||
CKFileExtension& operator=(CKFileExtension&& rhs) {
|
|
||||||
std::memmove(m_Data, rhs.m_Data, c_DataLen);
|
|
||||||
std::memset(rhs.m_Data, 0, c_DataLen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetExt(CKSTRING s) {
|
|
||||||
if (s == nullptr) {
|
|
||||||
m_Data[0] = '\0';
|
|
||||||
} else {
|
|
||||||
if (s[0] == '.') ++s; // skip dot
|
|
||||||
size_t len = std::strlen(s);
|
|
||||||
if (len > (c_DataLen - 1)) len = c_DataLen - 1;
|
|
||||||
std::memcpy(m_Data, s, len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CKSTRING GetExt() const {
|
|
||||||
return m_Data;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const CKFileExtension& rhs) const {
|
|
||||||
return CKStrEqualI(m_Data, rhs.m_Data);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static const size_t c_DataLen = 4u;
|
|
||||||
CKCHAR m_Data[c_DataLen];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The struct describe the bitmap handler's infomation,
|
|
||||||
* including its GUID and supported file extension.
|
|
||||||
* This struct also will store some parameters related to bitmap handler,
|
|
||||||
* such as jpeg compress level and etc. But currently there are no
|
|
||||||
* such parameters.
|
|
||||||
*/
|
|
||||||
class CKBitmapProperties {
|
|
||||||
public:
|
|
||||||
CKBitmapProperties() :
|
|
||||||
m_ReaderGuid(), m_Ext() {}
|
|
||||||
CKBitmapProperties(const CKGUID& guid, CKSTRING ext) :
|
|
||||||
m_ReaderGuid(guid), m_Ext(ext) {}
|
|
||||||
LIBCMO_DEFAULT_COPY_MOVE(CKBitmapProperties);
|
|
||||||
|
|
||||||
CKGUID m_ReaderGuid; /**< CKGUID that uniquely identifies the reader that created this properties structure */
|
|
||||||
CKFileExtension m_Ext; /**< File Extension of the image being described by this structure */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ namespace LibCmo::CK2::DataHandlers {
|
||||||
// write data
|
// write data
|
||||||
MemorySaveContext* ctx = new MemorySaveContext(memory);
|
MemorySaveContext* ctx = new MemorySaveContext(memory);
|
||||||
int ret = oper(
|
int ret = oper(
|
||||||
&FileWriteFunction, ctx,
|
&MemoryWriteFunction, ctx,
|
||||||
static_cast<int>(write_image->GetWidth()), static_cast<int>(write_image->GetHeight()),
|
static_cast<int>(write_image->GetWidth()), static_cast<int>(write_image->GetHeight()),
|
||||||
4, data // 4 == RGBA8888
|
4, data // 4 == RGBA8888
|
||||||
);
|
);
|
||||||
|
@ -208,11 +208,11 @@ namespace LibCmo::CK2::DataHandlers {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKBitmapBMPHandler::ReadFile(CKSTRING u8filename, VxMath::VxImageDescEx* read_image) {
|
bool CKBitmapBMPHandler::ReadFile(CKSTRING u8filename, VxMath::VxImageDescEx* read_image) {
|
||||||
StbReadFile(u8filename, read_image);
|
return StbReadFile(u8filename, read_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKBitmapBMPHandler::ReadMemory(const void* memory, CKDWORD size, VxMath::VxImageDescEx* read_image) {
|
bool CKBitmapBMPHandler::ReadMemory(const void* memory, CKDWORD size, VxMath::VxImageDescEx* read_image) {
|
||||||
StbReadMemory(memory, size, read_image);
|
return StbReadMemory(memory, size, read_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKBitmapBMPHandler::SaveFile(CKSTRING u8filename, const VxMath::VxImageDescEx* write_image, const CKBitmapProperties& codec_param) {
|
bool CKBitmapBMPHandler::SaveFile(CKSTRING u8filename, const VxMath::VxImageDescEx* write_image, const CKBitmapProperties& codec_param) {
|
||||||
|
@ -245,11 +245,11 @@ namespace LibCmo::CK2::DataHandlers {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKBitmapTGAHandler::ReadFile(CKSTRING u8filename, VxMath::VxImageDescEx* read_image) {
|
bool CKBitmapTGAHandler::ReadFile(CKSTRING u8filename, VxMath::VxImageDescEx* read_image) {
|
||||||
StbReadFile(u8filename, read_image);
|
return StbReadFile(u8filename, read_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKBitmapTGAHandler::ReadMemory(const void* memory, CKDWORD size, VxMath::VxImageDescEx* read_image) {
|
bool CKBitmapTGAHandler::ReadMemory(const void* memory, CKDWORD size, VxMath::VxImageDescEx* read_image) {
|
||||||
StbReadMemory(memory, size, read_image);
|
return StbReadMemory(memory, size, read_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKBitmapTGAHandler::SaveFile(CKSTRING u8filename, const VxMath::VxImageDescEx* write_image, const CKBitmapProperties& codec_param) {
|
bool CKBitmapTGAHandler::SaveFile(CKSTRING u8filename, const VxMath::VxImageDescEx* write_image, const CKBitmapProperties& codec_param) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace LibCmo::CK2::MgrImpls {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKPathManager::AddPath(CKSTRING u8path) {
|
bool CKPathManager::AddPath(CKSTRING u8path) {
|
||||||
if (u8path == nullptr) return;
|
if (u8path == nullptr) return false;
|
||||||
std::filesystem::path newpath;
|
std::filesystem::path newpath;
|
||||||
EncodingHelper::U8PathToStdPath(newpath, u8path);
|
EncodingHelper::U8PathToStdPath(newpath, u8path);
|
||||||
if (std::filesystem::is_directory(newpath)) {
|
if (std::filesystem::is_directory(newpath)) {
|
||||||
|
@ -86,7 +86,7 @@ namespace LibCmo::CK2::MgrImpls {
|
||||||
// test in temp folder
|
// test in temp folder
|
||||||
auto tempfile = m_TempFolder / filepath;
|
auto tempfile = m_TempFolder / filepath;
|
||||||
if (std::filesystem::is_regular_file(tempfile)) {
|
if (std::filesystem::is_regular_file(tempfile)) {
|
||||||
EncodingHelper::StdPathToU8Path(u8_filename, combinedpath);
|
EncodingHelper::StdPathToU8Path(u8_filename, tempfile);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,7 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="CK2\CKBitmapData.cpp" />
|
||||||
<ClCompile Include="CK2\CKFileOthers.cpp" />
|
<ClCompile Include="CK2\CKFileOthers.cpp" />
|
||||||
<ClCompile Include="CK2\CKFileWriter.cpp" />
|
<ClCompile Include="CK2\CKFileWriter.cpp" />
|
||||||
<ClCompile Include="CK2\CKGlobals.cpp" />
|
<ClCompile Include="CK2\CKGlobals.cpp" />
|
||||||
|
@ -199,11 +200,13 @@
|
||||||
<ClCompile Include="XContainer\XBitArray.cpp" />
|
<ClCompile Include="XContainer\XBitArray.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="CK2\CKBitmapData.hpp" />
|
||||||
<ClInclude Include="CK2\CKDefines.hpp" />
|
<ClInclude Include="CK2\CKDefines.hpp" />
|
||||||
<ClInclude Include="CK2\CKEnums.hpp" />
|
<ClInclude Include="CK2\CKEnums.hpp" />
|
||||||
<ClInclude Include="CK2\CKFile.hpp" />
|
<ClInclude Include="CK2\CKFile.hpp" />
|
||||||
<ClInclude Include="CK2\CKGlobals.hpp" />
|
<ClInclude Include="CK2\CKGlobals.hpp" />
|
||||||
<ClInclude Include="CK2\CKIdentifiers.hpp" />
|
<ClInclude Include="CK2\CKIdentifiers.hpp" />
|
||||||
|
<ClInclude Include="CK2\CKStructs.hpp" />
|
||||||
<ClInclude Include="CK2\DataHandlers\CKBitmapHandler.hpp" />
|
<ClInclude Include="CK2\DataHandlers\CKBitmapHandler.hpp" />
|
||||||
<ClInclude Include="CK2\MgrImpls\CKBaseManager.hpp" />
|
<ClInclude Include="CK2\MgrImpls\CKBaseManager.hpp" />
|
||||||
<ClInclude Include="CK2\CKContext.hpp" />
|
<ClInclude Include="CK2\CKContext.hpp" />
|
||||||
|
|
|
@ -117,6 +117,9 @@
|
||||||
<ClCompile Include="VxMath\VxMath.cpp">
|
<ClCompile Include="VxMath\VxMath.cpp">
|
||||||
<Filter>Sources\VxMath</Filter>
|
<Filter>Sources\VxMath</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="CK2\CKBitmapData.cpp">
|
||||||
|
<Filter>Sources\CK2</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="VTUtils.hpp">
|
<ClInclude Include="VTUtils.hpp">
|
||||||
|
@ -203,5 +206,11 @@
|
||||||
<ClInclude Include="CK2\DataHandlers\CKBitmapHandler.hpp">
|
<ClInclude Include="CK2\DataHandlers\CKBitmapHandler.hpp">
|
||||||
<Filter>Headers\CK2\DataHandlers</Filter>
|
<Filter>Headers\CK2\DataHandlers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="CK2\CKStructs.hpp">
|
||||||
|
<Filter>Headers\CK2</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="CK2\CKBitmapData.hpp">
|
||||||
|
<Filter>Headers\CK2</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -21,6 +21,7 @@ Except the file listed in there, they should include "VTUtils.hpp" first.
|
||||||
#include "CK2/CKEnums.hpp" // All CK used enums except CKStateChunk identifiers.
|
#include "CK2/CKEnums.hpp" // All CK used enums except CKStateChunk identifiers.
|
||||||
#include "CK2/CKIdentifiers.hpp" // CKStateChunk identifiers.
|
#include "CK2/CKIdentifiers.hpp" // CKStateChunk identifiers.
|
||||||
#include "CK2/CKGlobals.hpp" // CK global functions, such as CKUnPack and etc.
|
#include "CK2/CKGlobals.hpp" // CK global functions, such as CKUnPack and etc.
|
||||||
|
#include "CK2/CKStructs.hpp" // Some essential and useful classes + structs.
|
||||||
|
|
||||||
#include "VxMath/VxEnums.hpp"
|
#include "VxMath/VxEnums.hpp"
|
||||||
#include "VxMath/VxTypes.hpp"
|
#include "VxMath/VxTypes.hpp"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user