|
|
@ -2,20 +2,120 @@ |
|
|
#include "pch.h" |
|
|
#include "pch.h" |
|
|
#include "A2LFileData.h" |
|
|
#include "A2LFileData.h" |
|
|
|
|
|
|
|
|
|
|
|
CA2LFileData::Header::Header() |
|
|
|
|
|
{ |
|
|
|
|
|
m_strProjectNo = m_strComment = ""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CA2LFileData::Header::~Header() |
|
|
|
|
|
{ |
|
|
|
|
|
m_strProjectNo = m_strComment = ""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::string CA2LFileData::Header::GetComment() |
|
|
|
|
|
{ |
|
|
|
|
|
return m_strComment; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::string CA2LFileData::Header::GetProjectNo() |
|
|
|
|
|
{ |
|
|
|
|
|
return m_strProjectNo; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::string CA2LFileData::Header::GetVersion() |
|
|
|
|
|
{ |
|
|
|
|
|
return m_strVersion; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CA2LFileData::Header::SetComment(std::string strHeader) |
|
|
|
|
|
{ |
|
|
|
|
|
m_strComment = strHeader; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CA2LFileData::Header::SetProjectNo(std::string strProjectNo) |
|
|
|
|
|
{ |
|
|
|
|
|
m_strProjectNo = strProjectNo; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CA2LFileData::Header::SetVersion(std::string strVersion) |
|
|
|
|
|
{ |
|
|
|
|
|
m_strVersion = strVersion; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
CA2LFileData::CA2LFileData() |
|
|
CA2LFileData::CA2LFileData() |
|
|
{ |
|
|
{ |
|
|
|
|
|
m_pHeader = std::make_shared<CA2LFileData::Header>(); |
|
|
|
|
|
|
|
|
|
|
|
m_strA2lFilePath = ""; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
CA2LFileData::~CA2LFileData() |
|
|
CA2LFileData::~CA2LFileData() |
|
|
{ |
|
|
{ |
|
|
|
|
|
m_pHeader = nullptr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool CA2LFileData::LoadA2lFile(std::string strPath, bool bIsParse) |
|
|
|
|
|
{ |
|
|
|
|
|
bool bRet = false; |
|
|
|
|
|
|
|
|
|
|
|
if (m_pA2lFile != nullptr) { |
|
|
|
|
|
m_pA2lFile = nullptr; |
|
|
|
|
|
m_strA2lFilePath = ""; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_pA2lFile = std::make_shared<a2l::A2lFile>(); |
|
|
|
|
|
|
|
|
|
|
|
if (m_pA2lFile != nullptr) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
m_strA2lFilePath = strPath; |
|
|
|
|
|
bRet = std::filesystem::exists(strPath); |
|
|
|
|
|
} |
|
|
|
|
|
catch (const std::exception& error) { |
|
|
|
|
|
std::cout << "Failed to fetch the A2l test files. Error: " |
|
|
|
|
|
<< error.what(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_pA2lFile->Filename(strPath); |
|
|
|
|
|
|
|
|
|
|
|
if (bIsParse) |
|
|
|
|
|
ParseA2lFile(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
return bRet; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool CA2LFileData::LoadA2lFile(std::string strPath) |
|
|
bool CA2LFileData::ParseA2lFile() |
|
|
{ |
|
|
{ |
|
|
bool bRet = false; |
|
|
bool bRet = false; |
|
|
|
|
|
|
|
|
|
|
|
const auto parse = m_pA2lFile->ParseFile(); |
|
|
|
|
|
if (parse) { |
|
|
|
|
|
const auto& project = m_pA2lFile->Project(); |
|
|
|
|
|
|
|
|
|
|
|
const auto& header = project.Header(); |
|
|
|
|
|
|
|
|
|
|
|
m_pHeader->SetComment(header.Comment); |
|
|
|
|
|
m_pHeader->SetProjectNo(header.ProjectNo); |
|
|
|
|
|
m_pHeader->SetVersion(header.VersionNo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bRet = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return bRet; |
|
|
return bRet; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CA2LFileData::Header* CA2LFileData::GetHeader() |
|
|
|
|
|
{ |
|
|
|
|
|
if (m_pHeader != nullptr) |
|
|
|
|
|
return m_pHeader.get(); |
|
|
|
|
|
else |
|
|
|
|
|
return nullptr; |
|
|
|
|
|
} |