95 changed files with 39233 additions and 0 deletions
@ -0,0 +1,87 @@ |
|||
|
|||
// DlgProxy.cpp: 구현 파일
|
|||
//
|
|||
|
|||
#include "pch.h" |
|||
#include "framework.h" |
|||
#include "IncSourceTestDlg.h" |
|||
#include "DlgProxy.h" |
|||
#include "IncSourceTestDlgDlg.h" |
|||
|
|||
#ifdef _DEBUG |
|||
#define new DEBUG_NEW |
|||
#endif |
|||
|
|||
|
|||
// CIncSourceTestDlgDlgAutoProxy
|
|||
|
|||
IMPLEMENT_DYNCREATE(CIncSourceTestDlgDlgAutoProxy, CCmdTarget) |
|||
|
|||
CIncSourceTestDlgDlgAutoProxy::CIncSourceTestDlgDlgAutoProxy() |
|||
{ |
|||
EnableAutomation(); |
|||
|
|||
// 자동화 개체가 활성화되어 있는 동안 계속 애플리케이션을 실행하기 위해
|
|||
// 생성자에서 AfxOleLockApp를 호출합니다.
|
|||
AfxOleLockApp(); |
|||
|
|||
// 애플리케이션의 주 창 포인터를 통해 대화 상자에 대한
|
|||
// 액세스를 가져옵니다. 프록시의 내부 포인터를 설정하여
|
|||
// 대화 상자를 가리키고 대화 상자의 후방 포인터를 이 프록시로
|
|||
// 설정합니다.
|
|||
ASSERT_VALID(AfxGetApp()->m_pMainWnd); |
|||
if (AfxGetApp()->m_pMainWnd) |
|||
{ |
|||
ASSERT_KINDOF(CIncSourceTestDlgDlg, AfxGetApp()->m_pMainWnd); |
|||
if (AfxGetApp()->m_pMainWnd->IsKindOf(RUNTIME_CLASS(CIncSourceTestDlgDlg))) |
|||
{ |
|||
m_pDialog = reinterpret_cast<CIncSourceTestDlgDlg*>(AfxGetApp()->m_pMainWnd); |
|||
m_pDialog->m_pAutoProxy = this; |
|||
} |
|||
} |
|||
} |
|||
|
|||
CIncSourceTestDlgDlgAutoProxy::~CIncSourceTestDlgDlgAutoProxy() |
|||
{ |
|||
// 모든 개체가 OLE 자동화로 만들어졌을 때 애플리케이션을 종료하기 위해
|
|||
// 소멸자가 AfxOleUnlockApp를 호출합니다.
|
|||
// 이러한 호출로 주 대화 상자가 삭제될 수 있습니다.
|
|||
if (m_pDialog != nullptr) |
|||
m_pDialog->m_pAutoProxy = nullptr; |
|||
AfxOleUnlockApp(); |
|||
} |
|||
|
|||
void CIncSourceTestDlgDlgAutoProxy::OnFinalRelease() |
|||
{ |
|||
// 자동화 개체에 대한 마지막 참조가 해제되면
|
|||
// OnFinalRelease가 호출됩니다. 기본 클래스에서 자동으로 개체를 삭제합니다.
|
|||
// 기본 클래스를 호출하기 전에 개체에 필요한 추가 정리 작업을
|
|||
// 추가하세요.
|
|||
|
|||
CCmdTarget::OnFinalRelease(); |
|||
} |
|||
|
|||
BEGIN_MESSAGE_MAP(CIncSourceTestDlgDlgAutoProxy, CCmdTarget) |
|||
END_MESSAGE_MAP() |
|||
|
|||
BEGIN_DISPATCH_MAP(CIncSourceTestDlgDlgAutoProxy, CCmdTarget) |
|||
END_DISPATCH_MAP() |
|||
|
|||
// 참고: IID_IIncSourceTestDlg에 대한 지원을 추가하여
|
|||
// VBA에서 형식 안전 바인딩을 지원합니다.
|
|||
// 이 IID는 .IDL 파일에 있는 dispinterface의 GUID와 일치해야 합니다.
|
|||
|
|||
// {2ef56b3a-ca68-4764-8fdd-5d19ec609144}
|
|||
static const IID IID_IIncSourceTestDlg = |
|||
{0x2ef56b3a,0xca68,0x4764,{0x8f,0xdd,0x5d,0x19,0xec,0x60,0x91,0x44}}; |
|||
|
|||
BEGIN_INTERFACE_MAP(CIncSourceTestDlgDlgAutoProxy, CCmdTarget) |
|||
INTERFACE_PART(CIncSourceTestDlgDlgAutoProxy, IID_IIncSourceTestDlg, Dispatch) |
|||
END_INTERFACE_MAP() |
|||
|
|||
// IMPLEMENT_OLECREATE2 매크로가 이 프로젝트의 pch.h에 정의됩니다.
|
|||
// {485ee25e-0171-42b5-8cf0-7883ae87945e}
|
|||
IMPLEMENT_OLECREATE2(CIncSourceTestDlgDlgAutoProxy, "IncSourceTestDlg.Application", 0x485ee25e,0x0171,0x42b5,0x8c,0xf0,0x78,0x83,0xae,0x87,0x94,0x5e) |
|||
|
|||
|
|||
// CIncSourceTestDlgDlgAutoProxy 메시지 처리기
|
|||
@ -0,0 +1,43 @@ |
|||
|
|||
// DlgProxy.h: 헤더 파일
|
|||
//
|
|||
|
|||
#pragma once |
|||
|
|||
class CIncSourceTestDlgDlg; |
|||
|
|||
|
|||
// CIncSourceTestDlgDlgAutoProxy 명령 대상
|
|||
|
|||
class CIncSourceTestDlgDlgAutoProxy : public CCmdTarget |
|||
{ |
|||
DECLARE_DYNCREATE(CIncSourceTestDlgDlgAutoProxy) |
|||
|
|||
CIncSourceTestDlgDlgAutoProxy(); // 동적 만들기에 사용되는 protected 생성자입니다.
|
|||
|
|||
// 특성입니다.
|
|||
public: |
|||
CIncSourceTestDlgDlg* m_pDialog; |
|||
|
|||
// 작업입니다.
|
|||
public: |
|||
|
|||
// 재정의입니다.
|
|||
public: |
|||
virtual void OnFinalRelease(); |
|||
|
|||
// 구현입니다.
|
|||
protected: |
|||
virtual ~CIncSourceTestDlgDlgAutoProxy(); |
|||
|
|||
// 생성된 메시지 맵 함수
|
|||
|
|||
DECLARE_MESSAGE_MAP() |
|||
DECLARE_OLECREATE(CIncSourceTestDlgDlgAutoProxy) |
|||
|
|||
// 생성된 OLE 디스패치 맵 함수
|
|||
|
|||
DECLARE_DISPATCH_MAP() |
|||
DECLARE_INTERFACE_MAP() |
|||
}; |
|||
|
|||
@ -0,0 +1,153 @@ |
|||
|
|||
// IncSourceTestDlg.cpp: 애플리케이션에 대한 클래스 동작을 정의합니다.
|
|||
//
|
|||
|
|||
#include "pch.h" |
|||
#include "framework.h" |
|||
#include "IncSourceTestDlg.h" |
|||
#include "IncSourceTestDlgDlg.h" |
|||
|
|||
#ifdef _DEBUG |
|||
#define new DEBUG_NEW |
|||
#endif |
|||
|
|||
|
|||
// CIncSourceTestDlgApp
|
|||
|
|||
BEGIN_MESSAGE_MAP(CIncSourceTestDlgApp, CWinApp) |
|||
ON_COMMAND(ID_HELP, &CWinApp::OnHelp) |
|||
END_MESSAGE_MAP() |
|||
|
|||
|
|||
// CIncSourceTestDlgApp 생성
|
|||
|
|||
CIncSourceTestDlgApp::CIncSourceTestDlgApp() |
|||
{ |
|||
// 다시 시작 관리자 지원
|
|||
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; |
|||
|
|||
// TODO: 여기에 생성 코드를 추가합니다.
|
|||
// InitInstance에 모든 중요한 초기화 작업을 배치합니다.
|
|||
} |
|||
|
|||
|
|||
// 유일한 CIncSourceTestDlgApp 개체입니다.
|
|||
|
|||
CIncSourceTestDlgApp theApp; |
|||
|
|||
const GUID CDECL BASED_CODE _tlid = |
|||
{0xfdcaae6b,0x3d5c,0x4612,{0x8b,0xfc,0x6b,0x4e,0x40,0xf2,0x51,0x8d}}; |
|||
const WORD _wVerMajor = 1; |
|||
const WORD _wVerMinor = 0; |
|||
|
|||
|
|||
// CIncSourceTestDlgApp 초기화
|
|||
|
|||
BOOL CIncSourceTestDlgApp::InitInstance() |
|||
{ |
|||
// Windows XP에서는 InitCommonControlsEx()를 필요로 합니다.
|
|||
// 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다.
|
|||
// InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다.
|
|||
INITCOMMONCONTROLSEX InitCtrls; |
|||
InitCtrls.dwSize = sizeof(InitCtrls); |
|||
// 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록
|
|||
// 이 항목을 설정하십시오.
|
|||
InitCtrls.dwICC = ICC_WIN95_CLASSES; |
|||
InitCommonControlsEx(&InitCtrls); |
|||
|
|||
CWinApp::InitInstance(); |
|||
|
|||
|
|||
// OLE 라이브러리를 초기화합니다.
|
|||
if (!AfxOleInit()) |
|||
{ |
|||
AfxMessageBox(IDP_OLE_INIT_FAILED); |
|||
return FALSE; |
|||
} |
|||
|
|||
AfxEnableControlContainer(); |
|||
|
|||
// 대화 상자에 셸 트리 뷰 또는
|
|||
// 셸 목록 뷰 컨트롤이 포함되어 있는 경우 셸 관리자를 만듭니다.
|
|||
CShellManager *pShellManager = new CShellManager; |
|||
|
|||
// MFC 컨트롤의 테마를 사용하기 위해 "Windows 원형" 비주얼 관리자 활성화
|
|||
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); |
|||
|
|||
// 표준 초기화
|
|||
// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
|
|||
// 아래에서 필요 없는 특정 초기화
|
|||
// 루틴을 제거해야 합니다.
|
|||
// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
|
|||
// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
|
|||
// 적절한 내용으로 수정해야 합니다.
|
|||
SetRegistryKey(_T("로컬 애플리케이션 마법사에서 생성된 애플리케이션")); |
|||
// 자동화 또는 reg/unreg 스위치에 대한 명령줄을 구문 분석합니다.
|
|||
CCommandLineInfo cmdInfo; |
|||
ParseCommandLine(cmdInfo); |
|||
|
|||
// 응용 프로그램이 /Embedding 또는 /Automation 스위치로 시작되었습니다.
|
|||
// 응용 프로그램을 자동화 서버로 실행합니다.
|
|||
if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated) |
|||
{ |
|||
// CoRegisterClassObject()를 통해 클래스 팩터리를 등록합니다.
|
|||
COleTemplateServer::RegisterAll(); |
|||
} |
|||
// 응용 프로그램이 /Unregserver 또는 /Unregister 스위치로 시작되었습니다. 레지스트리에서 항목을
|
|||
// 제거합니다.
|
|||
else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister) |
|||
{ |
|||
COleObjectFactory::UpdateRegistryAll(FALSE); |
|||
AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor); |
|||
return FALSE; |
|||
} |
|||
// 응용 프로그램이 독립 실행형으로 시작되었거나 다른 스위치로 시작되었습니다(예: /Register
|
|||
// 또는 /Regserver). typelibrary를 포함하여 레지스트리 항목을 업데이트합니다.
|
|||
else |
|||
{ |
|||
COleObjectFactory::UpdateRegistryAll(); |
|||
AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid); |
|||
if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppRegister) |
|||
return FALSE; |
|||
} |
|||
|
|||
CIncSourceTestDlgDlg dlg; |
|||
m_pMainWnd = &dlg; |
|||
INT_PTR nResponse = dlg.DoModal(); |
|||
if (nResponse == IDOK) |
|||
{ |
|||
// TODO: 여기에 [확인]을 클릭하여 대화 상자가 없어질 때 처리할
|
|||
// 코드를 배치합니다.
|
|||
} |
|||
else if (nResponse == IDCANCEL) |
|||
{ |
|||
// TODO: 여기에 [취소]를 클릭하여 대화 상자가 없어질 때 처리할
|
|||
// 코드를 배치합니다.
|
|||
} |
|||
else if (nResponse == -1) |
|||
{ |
|||
TRACE(traceAppMsg, 0, "경고: 대화 상자를 만들지 못했으므로 애플리케이션이 예기치 않게 종료됩니다.\n"); |
|||
TRACE(traceAppMsg, 0, "경고: 대화 상자에서 MFC 컨트롤을 사용하는 경우 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS를 수행할 수 없습니다.\n"); |
|||
} |
|||
|
|||
// 위에서 만든 셸 관리자를 삭제합니다.
|
|||
if (pShellManager != nullptr) |
|||
{ |
|||
delete pShellManager; |
|||
} |
|||
|
|||
#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS) |
|||
ControlBarCleanUp(); |
|||
#endif |
|||
|
|||
// 대화 상자가 닫혔으므로 응용 프로그램의 메시지 펌프를 시작하지 않고 응용 프로그램을 끝낼 수 있도록 FALSE를
|
|||
// 반환합니다.
|
|||
return FALSE; |
|||
} |
|||
|
|||
int CIncSourceTestDlgApp::ExitInstance() |
|||
{ |
|||
AfxOleTerm(FALSE); |
|||
|
|||
return CWinApp::ExitInstance(); |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
|
|||
// IncSourceTestDlg.h: PROJECT_NAME 애플리케이션에 대한 주 헤더 파일입니다.
|
|||
//
|
|||
|
|||
#pragma once |
|||
|
|||
#ifndef __AFXWIN_H__ |
|||
#error "PCH에 대해 이 파일을 포함하기 전에 'pch.h'를 포함합니다." |
|||
#endif |
|||
|
|||
#include "resource.h" // 주 기호입니다. |
|||
|
|||
|
|||
// CIncSourceTestDlgApp:
|
|||
// 이 클래스의 구현에 대해서는 IncSourceTestDlg.cpp을(를) 참조하세요.
|
|||
//
|
|||
|
|||
class CIncSourceTestDlgApp : public CWinApp |
|||
{ |
|||
public: |
|||
CIncSourceTestDlgApp(); |
|||
|
|||
// 재정의입니다.
|
|||
public: |
|||
virtual BOOL InitInstance(); |
|||
virtual int ExitInstance(); |
|||
|
|||
// 구현입니다.
|
|||
|
|||
DECLARE_MESSAGE_MAP() |
|||
}; |
|||
|
|||
extern CIncSourceTestDlgApp theApp; |
|||
@ -0,0 +1,29 @@ |
|||
// IncSourceTestDlg.idl: IncSourceTestDlg.exe의 형식 라이브러리 소스 |
|||
|
|||
// 이 파일은 MIDL 컴파일러에 의해 처리되어 |
|||
// 형식 라이브러리(IncSourceTestDlg.tlb)입니다. |
|||
|
|||
[ uuid(fdcaae6b-3d5c-4612-8bfc-6b4e40f2518d), version(1.0) ] |
|||
library IncSourceTestDlg |
|||
{ |
|||
importlib("stdole32.tlb"); |
|||
importlib("stdole2.tlb"); |
|||
|
|||
// CIncSourceTestDlgDoc의 기본 디스패치 인터페이스 |
|||
|
|||
[ uuid(2ef56b3a-ca68-4764-8fdd-5d19ec609144) ] |
|||
dispinterface IIncSourceTestDlg |
|||
{ |
|||
properties: |
|||
|
|||
methods: |
|||
}; |
|||
|
|||
// CIncSourceTestDlgDoc에 대한 클래스 정보 |
|||
|
|||
[ uuid(485ee25e-0171-42b5-8cf0-7883ae87945e) ] |
|||
coclass IncSourceTestDlg |
|||
{ |
|||
[default] dispinterface IIncSourceTestDlg; |
|||
}; |
|||
}; |
|||
Binary file not shown.
@ -0,0 +1,17 @@ |
|||
REGEDIT |
|||
; .REG 파일은 SETUP 프로그램에 사용될 수 있습니다. |
|||
; SETUP 프로그램을 사용할 수 없는 경우 아래 항목이 |
|||
; CWinApp::RegisterShellFileTypes 및 COleObjectFactory::UpdateRegistryAll을 |
|||
; 호출하여 InitInstance에 자동으로 등록됩니다. |
|||
|
|||
|
|||
HKEY_CLASSES_ROOT\IncSourceTestDlg.Application = IncSourceTestDlg Application |
|||
|
|||
|
|||
HKEY_CLASSES_ROOT\IncSourceTestDlg.Application\CLSID = {485ee25e-0171-42b5-8cf0-7883ae87945e} |
|||
|
|||
HKEY_CLASSES_ROOT\CLSID\{485ee25e-0171-42b5-8cf0-7883ae87945e} = IncSourceTestDlg Application |
|||
HKEY_CLASSES_ROOT\CLSID\{485ee25e-0171-42b5-8cf0-7883ae87945e}\ProgId = IncSourceTestDlg.Application |
|||
|
|||
|
|||
HKEY_CLASSES_ROOT\CLSID\{485ee25e-0171-42b5-8cf0-7883ae87945e}\LocalServer32 = IncSourceTestDlg.EXE |
|||
@ -0,0 +1,286 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup Label="ProjectConfigurations"> |
|||
<ProjectConfiguration Include="Debug|Win32"> |
|||
<Configuration>Debug</Configuration> |
|||
<Platform>Win32</Platform> |
|||
</ProjectConfiguration> |
|||
<ProjectConfiguration Include="Release|Win32"> |
|||
<Configuration>Release</Configuration> |
|||
<Platform>Win32</Platform> |
|||
</ProjectConfiguration> |
|||
<ProjectConfiguration Include="Debug|x64"> |
|||
<Configuration>Debug</Configuration> |
|||
<Platform>x64</Platform> |
|||
</ProjectConfiguration> |
|||
<ProjectConfiguration Include="Release|x64"> |
|||
<Configuration>Release</Configuration> |
|||
<Platform>x64</Platform> |
|||
</ProjectConfiguration> |
|||
</ItemGroup> |
|||
<PropertyGroup Label="Globals"> |
|||
<VCProjectVersion>17.0</VCProjectVersion> |
|||
<ProjectGuid>{44739900-23B0-7EA4-48FA-099C6C559D77}</ProjectGuid> |
|||
<Keyword>MFCProj</Keyword> |
|||
<RootNamespace>IncSourceTestDlg</RootNamespace> |
|||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> |
|||
</PropertyGroup> |
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> |
|||
<ConfigurationType>Application</ConfigurationType> |
|||
<UseDebugLibraries>true</UseDebugLibraries> |
|||
<PlatformToolset>v143</PlatformToolset> |
|||
<CharacterSet>Unicode</CharacterSet> |
|||
<UseOfMfc>Dynamic</UseOfMfc> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> |
|||
<ConfigurationType>Application</ConfigurationType> |
|||
<UseDebugLibraries>false</UseDebugLibraries> |
|||
<PlatformToolset>v143</PlatformToolset> |
|||
<WholeProgramOptimization>true</WholeProgramOptimization> |
|||
<CharacterSet>Unicode</CharacterSet> |
|||
<UseOfMfc>Dynamic</UseOfMfc> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> |
|||
<ConfigurationType>Application</ConfigurationType> |
|||
<UseDebugLibraries>true</UseDebugLibraries> |
|||
<PlatformToolset>v143</PlatformToolset> |
|||
<CharacterSet>Unicode</CharacterSet> |
|||
<UseOfMfc>Dynamic</UseOfMfc> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> |
|||
<ConfigurationType>Application</ConfigurationType> |
|||
<UseDebugLibraries>false</UseDebugLibraries> |
|||
<PlatformToolset>v143</PlatformToolset> |
|||
<WholeProgramOptimization>true</WholeProgramOptimization> |
|||
<CharacterSet>Unicode</CharacterSet> |
|||
<UseOfMfc>Dynamic</UseOfMfc> |
|||
</PropertyGroup> |
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
|||
<ImportGroup Label="ExtensionSettings"> |
|||
</ImportGroup> |
|||
<ImportGroup Label="Shared"> |
|||
</ImportGroup> |
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
|||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
|||
</ImportGroup> |
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
|||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
|||
</ImportGroup> |
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
|||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
|||
</ImportGroup> |
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
|||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
|||
</ImportGroup> |
|||
<PropertyGroup Label="UserMacros" /> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
|||
<LinkIncremental>true</LinkIncremental> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
|||
<LinkIncremental>true</LinkIncremental> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
|||
<LinkIncremental>false</LinkIncremental> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
|||
<LinkIncremental>false</LinkIncremental> |
|||
</PropertyGroup> |
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
|||
<ClCompile> |
|||
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
|||
<WarningLevel>Level3</WarningLevel> |
|||
<SDLCheck>true</SDLCheck> |
|||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> |
|||
<AdditionalIncludeDirectories>C:\git_work\a2l\a2l_test\TestLibDlg\IncSourceTestDlg\include;C:\git_work\a2l\a2l_test\TestLibDlg\IncSourceTestDlg\src;C:\boost\include\boost-1_87;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
|||
<LanguageStandard>stdcpp20</LanguageStandard> |
|||
</ClCompile> |
|||
<Link> |
|||
<SubSystem>Windows</SubSystem> |
|||
<RegisterOutput>true</RegisterOutput> |
|||
<AdditionalLibraryDirectories>C:\boost\x86_lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
|||
</Link> |
|||
<Midl> |
|||
<MkTypLibCompatible>false</MkTypLibCompatible> |
|||
<ValidateAllParameters>true</ValidateAllParameters> |
|||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
<TypeLibraryName>$(IntDir)IncSourceTestDlg.tlb</TypeLibraryName> |
|||
<HeaderFileName>IncSourceTestDlg_h.h</HeaderFileName> |
|||
</Midl> |
|||
<ResourceCompile> |
|||
<Culture>0x0412</Culture> |
|||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
|||
</ResourceCompile> |
|||
</ItemDefinitionGroup> |
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
|||
<ClCompile> |
|||
<PrecompiledHeader>Use</PrecompiledHeader> |
|||
<WarningLevel>Level3</WarningLevel> |
|||
<SDLCheck>true</SDLCheck> |
|||
<PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> |
|||
</ClCompile> |
|||
<Link> |
|||
<SubSystem>Windows</SubSystem> |
|||
<RegisterOutput>true</RegisterOutput> |
|||
</Link> |
|||
<Midl> |
|||
<MkTypLibCompatible>false</MkTypLibCompatible> |
|||
<ValidateAllParameters>true</ValidateAllParameters> |
|||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
<TypeLibraryName>$(IntDir)IncSourceTestDlg.tlb</TypeLibraryName> |
|||
<HeaderFileName>IncSourceTestDlg_h.h</HeaderFileName> |
|||
</Midl> |
|||
<ResourceCompile> |
|||
<Culture>0x0412</Culture> |
|||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
|||
</ResourceCompile> |
|||
</ItemDefinitionGroup> |
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
|||
<ClCompile> |
|||
<PrecompiledHeader>Use</PrecompiledHeader> |
|||
<WarningLevel>Level3</WarningLevel> |
|||
<FunctionLevelLinking>true</FunctionLevelLinking> |
|||
<IntrinsicFunctions>true</IntrinsicFunctions> |
|||
<SDLCheck>true</SDLCheck> |
|||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> |
|||
</ClCompile> |
|||
<Link> |
|||
<SubSystem>Windows</SubSystem> |
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
|||
<OptimizeReferences>true</OptimizeReferences> |
|||
<RegisterOutput>true</RegisterOutput> |
|||
</Link> |
|||
<Midl> |
|||
<MkTypLibCompatible>false</MkTypLibCompatible> |
|||
<ValidateAllParameters>true</ValidateAllParameters> |
|||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
<TypeLibraryName>$(IntDir)IncSourceTestDlg.tlb</TypeLibraryName> |
|||
<HeaderFileName>IncSourceTestDlg_h.h</HeaderFileName> |
|||
</Midl> |
|||
<ResourceCompile> |
|||
<Culture>0x0412</Culture> |
|||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
|||
</ResourceCompile> |
|||
</ItemDefinitionGroup> |
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
|||
<ClCompile> |
|||
<PrecompiledHeader>Use</PrecompiledHeader> |
|||
<WarningLevel>Level3</WarningLevel> |
|||
<FunctionLevelLinking>true</FunctionLevelLinking> |
|||
<IntrinsicFunctions>true</IntrinsicFunctions> |
|||
<SDLCheck>true</SDLCheck> |
|||
<PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> |
|||
</ClCompile> |
|||
<Link> |
|||
<SubSystem>Windows</SubSystem> |
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
|||
<OptimizeReferences>true</OptimizeReferences> |
|||
<RegisterOutput>true</RegisterOutput> |
|||
</Link> |
|||
<Midl> |
|||
<MkTypLibCompatible>false</MkTypLibCompatible> |
|||
<ValidateAllParameters>true</ValidateAllParameters> |
|||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
<TypeLibraryName>$(IntDir)IncSourceTestDlg.tlb</TypeLibraryName> |
|||
<HeaderFileName>IncSourceTestDlg_h.h</HeaderFileName> |
|||
</Midl> |
|||
<ResourceCompile> |
|||
<Culture>0x0412</Culture> |
|||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
|||
</ResourceCompile> |
|||
</ItemDefinitionGroup> |
|||
<ItemGroup> |
|||
<ClInclude Include="DlgProxy.h" /> |
|||
<ClInclude Include="framework.h" /> |
|||
<ClInclude Include="IncSourceTestDlg.h" /> |
|||
<ClInclude Include="IncSourceTestDlgDlg.h" /> |
|||
<ClInclude Include="pch.h" /> |
|||
<ClInclude Include="Resource.h" /> |
|||
<ClInclude Include="src\a2lhelper.h" /> |
|||
<ClInclude Include="src\a2lparser.hpp" /> |
|||
<ClInclude Include="src\a2lscanner.h" /> |
|||
<ClInclude Include="src\a2mlparser.hpp" /> |
|||
<ClInclude Include="src\a2mlscanner.h" /> |
|||
<ClInclude Include="src\FlexLexer.h" /> |
|||
<ClInclude Include="src\ifdataparser.hpp" /> |
|||
<ClInclude Include="src\ifdatascanner.h" /> |
|||
<ClInclude Include="targetver.h" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ClCompile Include="DlgProxy.cpp" /> |
|||
<ClCompile Include="IncSourceTestDlg.cpp" /> |
|||
<ClCompile Include="IncSourceTestDlgDlg.cpp" /> |
|||
<ClCompile Include="pch.cpp"> |
|||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> |
|||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> |
|||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> |
|||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2lenums.cpp" /> |
|||
<ClCompile Include="src\a2lfile.cpp" /> |
|||
<ClCompile Include="src\a2lflexer.cpp" /> |
|||
<ClCompile Include="src\a2lhelper.cpp" /> |
|||
<ClCompile Include="src\a2lobject.cpp" /> |
|||
<ClCompile Include="src\a2lparser.cpp" /> |
|||
<ClCompile Include="src\a2lproject.cpp" /> |
|||
<ClCompile Include="src\a2lscanner.cpp" /> |
|||
<ClCompile Include="src\a2mlblock.cpp" /> |
|||
<ClCompile Include="src\a2mlflexer.cpp" /> |
|||
<ClCompile Include="src\a2mlobject.cpp" /> |
|||
<ClCompile Include="src\a2mlparser.cpp" /> |
|||
<ClCompile Include="src\a2mlscanner.cpp" /> |
|||
<ClCompile Include="src\axisdescr.cpp" /> |
|||
<ClCompile Include="src\axispts.cpp" /> |
|||
<ClCompile Include="src\blob.cpp" /> |
|||
<ClCompile Include="src\characteristic.cpp" /> |
|||
<ClCompile Include="src\compumethod.cpp" /> |
|||
<ClCompile Include="src\computab.cpp" /> |
|||
<ClCompile Include="src\compuvtab.cpp" /> |
|||
<ClCompile Include="src\compuvtabrange.cpp" /> |
|||
<ClCompile Include="src\frame.cpp" /> |
|||
<ClCompile Include="src\function.cpp" /> |
|||
<ClCompile Include="src\group.cpp" /> |
|||
<ClCompile Include="src\ifdatablock.cpp" /> |
|||
<ClCompile Include="src\ifdataflexer.cpp" /> |
|||
<ClCompile Include="src\ifdataparser.cpp" /> |
|||
<ClCompile Include="src\ifdatascanner.cpp" /> |
|||
<ClCompile Include="src\instance.cpp" /> |
|||
<ClCompile Include="src\measurement.cpp" /> |
|||
<ClCompile Include="src\module.cpp" /> |
|||
<ClCompile Include="src\overwrite.cpp" /> |
|||
<ClCompile Include="src\recordlayout.cpp" /> |
|||
<ClCompile Include="src\structure.cpp" /> |
|||
<ClCompile Include="src\transformer.cpp" /> |
|||
<ClCompile Include="src\unit.cpp" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Midl Include="IncSourceTestDlg.idl" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="IncSourceTestDlg.reg" /> |
|||
<None Include="res\IncSourceTestDlg.rc2" /> |
|||
<None Include="src\a2lflexer.l" /> |
|||
<None Include="src\a2lparser.y" /> |
|||
<None Include="src\a2mlflexer.l" /> |
|||
<None Include="src\a2mlparser.y" /> |
|||
<None Include="src\ifdataflexer.l" /> |
|||
<None Include="src\ifdataparser.y" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ResourceCompile Include="IncSourceTestDlg.rc" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Image Include="res\IncSourceTestDlg.ico" /> |
|||
</ItemGroup> |
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
|||
<ImportGroup Label="ExtensionTargets"> |
|||
</ImportGroup> |
|||
</Project> |
|||
@ -0,0 +1,228 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<Filter Include="소스 파일"> |
|||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> |
|||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> |
|||
</Filter> |
|||
<Filter Include="헤더 파일"> |
|||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> |
|||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions> |
|||
</Filter> |
|||
<Filter Include="리소스 파일"> |
|||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> |
|||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> |
|||
</Filter> |
|||
<Filter Include="src"> |
|||
<UniqueIdentifier>{ab092bfb-4c1e-40f2-bfa9-349fda25fa4c}</UniqueIdentifier> |
|||
</Filter> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ClInclude Include="IncSourceTestDlg.h"> |
|||
<Filter>헤더 파일</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="IncSourceTestDlgDlg.h"> |
|||
<Filter>헤더 파일</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="DlgProxy.h"> |
|||
<Filter>헤더 파일</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="framework.h"> |
|||
<Filter>헤더 파일</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="targetver.h"> |
|||
<Filter>헤더 파일</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="Resource.h"> |
|||
<Filter>헤더 파일</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="pch.h"> |
|||
<Filter>헤더 파일</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="src\a2lhelper.h"> |
|||
<Filter>src</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="src\a2lparser.hpp"> |
|||
<Filter>src</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="src\a2lscanner.h"> |
|||
<Filter>src</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="src\a2mlparser.hpp"> |
|||
<Filter>src</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="src\a2mlscanner.h"> |
|||
<Filter>src</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="src\FlexLexer.h"> |
|||
<Filter>src</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="src\ifdataparser.hpp"> |
|||
<Filter>src</Filter> |
|||
</ClInclude> |
|||
<ClInclude Include="src\ifdatascanner.h"> |
|||
<Filter>src</Filter> |
|||
</ClInclude> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ClCompile Include="IncSourceTestDlg.cpp"> |
|||
<Filter>소스 파일</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="IncSourceTestDlgDlg.cpp"> |
|||
<Filter>소스 파일</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="DlgProxy.cpp"> |
|||
<Filter>소스 파일</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="pch.cpp"> |
|||
<Filter>소스 파일</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2lenums.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2lfile.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2lflexer.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2lhelper.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2lobject.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2lparser.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2lproject.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2lscanner.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2mlblock.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2mlflexer.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2mlobject.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2mlparser.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\a2mlscanner.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\axisdescr.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\axispts.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\blob.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\characteristic.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\compumethod.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\computab.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\compuvtab.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\compuvtabrange.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\frame.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\function.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\group.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\ifdatablock.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\ifdataflexer.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\ifdataparser.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\ifdatascanner.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\instance.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\measurement.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\module.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\overwrite.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\recordlayout.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\structure.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\transformer.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
<ClCompile Include="src\unit.cpp"> |
|||
<Filter>src</Filter> |
|||
</ClCompile> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Midl Include="IncSourceTestDlg.idl"> |
|||
<Filter>소스 파일</Filter> |
|||
</Midl> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="IncSourceTestDlg.reg" /> |
|||
<None Include="res\IncSourceTestDlg.rc2"> |
|||
<Filter>리소스 파일</Filter> |
|||
</None> |
|||
<None Include="src\a2lflexer.l"> |
|||
<Filter>src</Filter> |
|||
</None> |
|||
<None Include="src\a2lparser.y"> |
|||
<Filter>src</Filter> |
|||
</None> |
|||
<None Include="src\a2mlflexer.l"> |
|||
<Filter>src</Filter> |
|||
</None> |
|||
<None Include="src\a2mlparser.y"> |
|||
<Filter>src</Filter> |
|||
</None> |
|||
<None Include="src\ifdataflexer.l"> |
|||
<Filter>src</Filter> |
|||
</None> |
|||
<None Include="src\ifdataparser.y"> |
|||
<Filter>src</Filter> |
|||
</None> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ResourceCompile Include="IncSourceTestDlg.rc"> |
|||
<Filter>리소스 파일</Filter> |
|||
</ResourceCompile> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Image Include="res\IncSourceTestDlg.ico"> |
|||
<Filter>리소스 파일</Filter> |
|||
</Image> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,6 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<RESOURCE_FILE>IncSourceTestDlg.rc</RESOURCE_FILE> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -0,0 +1,590 @@ |
|||
|
|||
// IncSourceTestDlgDlg.cpp: 구현 파일
|
|||
//
|
|||
|
|||
#include "pch.h" |
|||
#include "framework.h" |
|||
#include "IncSourceTestDlg.h" |
|||
#include "IncSourceTestDlgDlg.h" |
|||
#include "DlgProxy.h" |
|||
#include "afxdialogex.h" |
|||
|
|||
#include <iostream> |
|||
|
|||
#ifdef _DEBUG |
|||
#define new DEBUG_NEW |
|||
#endif |
|||
|
|||
|
|||
//template<typename ... Args>
|
|||
//std::wstring wstring_format(const std::wstring& format, Args ... args);
|
|||
template<typename ... Args> |
|||
std::string string_format(const std::string& format, Args ... args) |
|||
{ |
|||
size_t size = snprintf(nullptr, 0, format.c_str(), args ...) + 1; // Extra space for '\0'
|
|||
if (size <= 0) { |
|||
throw std::runtime_error("Error during formatting."); |
|||
} |
|||
std::unique_ptr<char[]> buf(new char[size]); |
|||
snprintf(buf.get(), size, format.c_str(), args ...); |
|||
return std::string(buf.get(), buf.get() + size - 1); // We don't want the '\0' inside }
|
|||
} |
|||
|
|||
|
|||
// 응용 프로그램 정보에 사용되는 CAboutDlg 대화 상자입니다.
|
|||
|
|||
class CAboutDlg : public CDialogEx |
|||
{ |
|||
public: |
|||
CAboutDlg(); |
|||
|
|||
// 대화 상자 데이터입니다.
|
|||
#ifdef AFX_DESIGN_TIME |
|||
enum { IDD = IDD_ABOUTBOX }; |
|||
#endif |
|||
|
|||
protected: |
|||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
|
|||
|
|||
// 구현입니다.
|
|||
protected: |
|||
DECLARE_MESSAGE_MAP() |
|||
}; |
|||
|
|||
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX) |
|||
{ |
|||
} |
|||
|
|||
void CAboutDlg::DoDataExchange(CDataExchange* pDX) |
|||
{ |
|||
CDialogEx::DoDataExchange(pDX); |
|||
} |
|||
|
|||
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) |
|||
END_MESSAGE_MAP() |
|||
|
|||
|
|||
// CIncSourceTestDlgDlg 대화 상자
|
|||
|
|||
|
|||
IMPLEMENT_DYNAMIC(CIncSourceTestDlgDlg, CDialogEx); |
|||
|
|||
CIncSourceTestDlgDlg::CIncSourceTestDlgDlg(CWnd* pParent /*=nullptr*/) |
|||
: CDialogEx(IDD_INCSOURCETESTDLG_DIALOG, pParent) |
|||
{ |
|||
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); |
|||
m_pAutoProxy = nullptr; |
|||
} |
|||
|
|||
CIncSourceTestDlgDlg::~CIncSourceTestDlgDlg() |
|||
{ |
|||
// 이 대화 상자에 대한 자동화 프록시가 있을 경우 이 대화 상자에 대한
|
|||
// 후방 포인터를 null로 설정하여
|
|||
// 대화 상자가 삭제되었음을 알 수 있게 합니다.
|
|||
if (m_pAutoProxy != nullptr) |
|||
m_pAutoProxy->m_pDialog = nullptr; |
|||
} |
|||
|
|||
void CIncSourceTestDlgDlg::DoDataExchange(CDataExchange* pDX) |
|||
{ |
|||
CDialogEx::DoDataExchange(pDX); |
|||
} |
|||
|
|||
BEGIN_MESSAGE_MAP(CIncSourceTestDlgDlg, CDialogEx) |
|||
ON_WM_SYSCOMMAND() |
|||
ON_WM_CLOSE() |
|||
ON_WM_PAINT() |
|||
ON_WM_QUERYDRAGICON() |
|||
ON_BN_CLICKED(IDC_BUTTON_OPEN, &CIncSourceTestDlgDlg::OnBnClickedButtonOpen) |
|||
END_MESSAGE_MAP() |
|||
|
|||
|
|||
// CIncSourceTestDlgDlg 메시지 처리기
|
|||
|
|||
BOOL CIncSourceTestDlgDlg::OnInitDialog() |
|||
{ |
|||
CDialogEx::OnInitDialog(); |
|||
|
|||
// 시스템 메뉴에 "정보..." 메뉴 항목을 추가합니다.
|
|||
|
|||
// IDM_ABOUTBOX는 시스템 명령 범위에 있어야 합니다.
|
|||
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); |
|||
ASSERT(IDM_ABOUTBOX < 0xF000); |
|||
|
|||
CMenu* pSysMenu = GetSystemMenu(FALSE); |
|||
if (pSysMenu != nullptr) |
|||
{ |
|||
BOOL bNameValid; |
|||
CString strAboutMenu; |
|||
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); |
|||
ASSERT(bNameValid); |
|||
if (!strAboutMenu.IsEmpty()) |
|||
{ |
|||
pSysMenu->AppendMenu(MF_SEPARATOR); |
|||
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); |
|||
} |
|||
} |
|||
|
|||
// 이 대화 상자의 아이콘을 설정합니다. 응용 프로그램의 주 창이 대화 상자가 아닐 경우에는
|
|||
// 프레임워크가 이 작업을 자동으로 수행합니다.
|
|||
SetIcon(m_hIcon, TRUE); // 큰 아이콘을 설정합니다.
|
|||
SetIcon(m_hIcon, FALSE); // 작은 아이콘을 설정합니다.
|
|||
|
|||
// TODO: 여기에 추가 초기화 작업을 추가합니다.
|
|||
|
|||
return TRUE; // 포커스를 컨트롤에 설정하지 않으면 TRUE를 반환합니다.
|
|||
} |
|||
|
|||
void CIncSourceTestDlgDlg::OnSysCommand(UINT nID, LPARAM lParam) |
|||
{ |
|||
if ((nID & 0xFFF0) == IDM_ABOUTBOX) |
|||
{ |
|||
CAboutDlg dlgAbout; |
|||
dlgAbout.DoModal(); |
|||
} |
|||
else |
|||
{ |
|||
CDialogEx::OnSysCommand(nID, lParam); |
|||
} |
|||
} |
|||
|
|||
// 대화 상자에 최소화 단추를 추가할 경우 아이콘을 그리려면
|
|||
// 아래 코드가 필요합니다. 문서/뷰 모델을 사용하는 MFC 애플리케이션의 경우에는
|
|||
// 프레임워크에서 이 작업을 자동으로 수행합니다.
|
|||
|
|||
void CIncSourceTestDlgDlg::OnPaint() |
|||
{ |
|||
if (IsIconic()) |
|||
{ |
|||
CPaintDC dc(this); // 그리기를 위한 디바이스 컨텍스트입니다.
|
|||
|
|||
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); |
|||
|
|||
// 클라이언트 사각형에서 아이콘을 가운데에 맞춥니다.
|
|||
int cxIcon = GetSystemMetrics(SM_CXICON); |
|||
int cyIcon = GetSystemMetrics(SM_CYICON); |
|||
CRect rect; |
|||
GetClientRect(&rect); |
|||
int x = (rect.Width() - cxIcon + 1) / 2; |
|||
int y = (rect.Height() - cyIcon + 1) / 2; |
|||
|
|||
// 아이콘을 그립니다.
|
|||
dc.DrawIcon(x, y, m_hIcon); |
|||
} |
|||
else |
|||
{ |
|||
CDialogEx::OnPaint(); |
|||
} |
|||
} |
|||
|
|||
// 사용자가 최소화된 창을 끄는 동안에 커서가 표시되도록 시스템에서
|
|||
// 이 함수를 호출합니다.
|
|||
HCURSOR CIncSourceTestDlgDlg::OnQueryDragIcon() |
|||
{ |
|||
return static_cast<HCURSOR>(m_hIcon); |
|||
} |
|||
|
|||
// 컨트롤러에서 해당 개체 중 하나를 계속 사용하고 있을 경우
|
|||
// 사용자가 UI를 닫을 때 자동화 서버를 종료하면 안 됩니다. 이들
|
|||
// 메시지 처리기는 프록시가 아직 사용 중인 경우 UI는 숨기지만,
|
|||
// UI가 표시되지 않아도 대화 상자는
|
|||
// 남겨 둡니다.
|
|||
|
|||
void CIncSourceTestDlgDlg::OnClose() |
|||
{ |
|||
if (CanExit()) |
|||
CDialogEx::OnClose(); |
|||
} |
|||
|
|||
void CIncSourceTestDlgDlg::OnOK() |
|||
{ |
|||
if (CanExit()) |
|||
CDialogEx::OnOK(); |
|||
} |
|||
|
|||
void CIncSourceTestDlgDlg::OnCancel() |
|||
{ |
|||
if (CanExit()) |
|||
CDialogEx::OnCancel(); |
|||
} |
|||
|
|||
BOOL CIncSourceTestDlgDlg::CanExit() |
|||
{ |
|||
// 프록시 개체가 계속 남아 있으면 자동화 컨트롤러에서는
|
|||
// 이 애플리케이션을 계속 사용합니다. 대화 상자는 남겨 두지만
|
|||
// 해당 UI는 숨깁니다.
|
|||
if (m_pAutoProxy != nullptr) |
|||
{ |
|||
ShowWindow(SW_HIDE); |
|||
return FALSE; |
|||
} |
|||
|
|||
return TRUE; |
|||
} |
|||
|
|||
|
|||
void CIncSourceTestDlgDlg::OnBnClickedButtonOpen() |
|||
{ |
|||
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
|||
TCHAR a2lExt[] = _T("*.a2l"); |
|||
TCHAR a2lBaseFilter[] = _T("A2L file(*.A2L) | *.a2l;*.A2L | 모든파일(*.*) | *.* ||"); |
|||
CFileDialog dlg(TRUE, a2lExt, NULL, OFN_HIDEREADONLY, a2lBaseFilter); |
|||
|
|||
if (dlg.DoModal() == IDOK) { |
|||
std::wstring strPath = dlg.GetPathName().GetBuffer(); |
|||
|
|||
std::string strA2lPath; |
|||
|
|||
strA2lPath.assign(strPath.begin(), strPath.end()); |
|||
|
|||
loadA2lFile(strA2lPath.c_str()); |
|||
} |
|||
} |
|||
|
|||
void CIncSourceTestDlgDlg::loadA2lFile(std::string strFilePath) |
|||
{ |
|||
std::string strLogData; |
|||
|
|||
bool bIsFileExist = false; |
|||
try { |
|||
bIsFileExist = std::filesystem::exists(strFilePath); |
|||
} |
|||
catch (const std::exception& error) { |
|||
std::cout << "Failed to fetch the A2l test files. Error: " |
|||
<< error.what(); |
|||
} |
|||
|
|||
a2l::A2lFile file; |
|||
file.Filename(strFilePath.data()); |
|||
const auto parse = file.ParseFile(); |
|||
if (parse) |
|||
std::cout << file.LastError() << " : " << strFilePath.data(); |
|||
std::cout << file.Name() << (parse ? " : OK" : " : FAIL") << std::endl; |
|||
|
|||
AddLogString(strFilePath.data()); |
|||
|
|||
|
|||
//if (file.A2lVersion().VersionNo == 1)
|
|||
// ;
|
|||
std::cout << file.A2lVersion().VersionNo << " : " << file.A2lVersion().VersionNo; |
|||
AddLogString(string_format("file.A2lVersion().VersionNo : %d", file.A2lVersion().VersionNo)); |
|||
|
|||
//if (file.A2lVersion().UpgradeNo == 71)
|
|||
// ;
|
|||
std::cout << file.A2lVersion().UpgradeNo << " : " << file.A2lVersion().UpgradeNo; |
|||
AddLogString(string_format("file.A2lVersion().UpgradeNo : %d", file.A2lVersion().UpgradeNo)); |
|||
|
|||
const auto& project = file.Project(); |
|||
|
|||
const auto& header = project.Header(); |
|||
//EXPECT_FALSE(header.Comment.empty());
|
|||
//EXPECT_FALSE(header.ProjectNo.empty());
|
|||
//EXPECT_FALSE(header.VersionNo.empty());
|
|||
std::cout << header.Comment << " : " << header.Comment; |
|||
AddLogString(string_format("header.Comment : %s", header.Comment.c_str())); |
|||
std::cout << header.ProjectNo << " : " << header.ProjectNo; |
|||
AddLogString(string_format("header.ProjectNo : %s", header.ProjectNo.c_str())); |
|||
std::cout << header.VersionNo << " : " << header.VersionNo; |
|||
AddLogString(string_format("header.VersionNo : %s", header.VersionNo.c_str())); |
|||
|
|||
const auto& module_list = project.Modules(); |
|||
//ASSERT_EQ(module_list.size(), 1);
|
|||
std::cout << module_list.size() << " : " << module_list.size(); |
|||
AddLogString(string_format("module_list.size() : %d", module_list.size())); |
|||
|
|||
if (module_list.size() > 0) { |
|||
|
|||
const auto& module = module_list.cbegin()->second; |
|||
//ASSERT_TRUE(module);
|
|||
|
|||
//EXPECT_STREQ(module->Name().c_str(), "Example");
|
|||
//EXPECT_FALSE(module->A2ml().empty());
|
|||
AddLogString(string_format("module->Name() : %s", module->Name().c_str())); |
|||
AddLogString(string_format("module->A2ml() : %s", module->A2ml().c_str())); |
|||
|
|||
AddLogString(""); |
|||
|
|||
const auto& modPar = module->ModPar(); |
|||
AddLogString(string_format("modPar.Comment() : %s", modPar.Comment.c_str())); |
|||
AddLogString(string_format("modPar.epk : %s", modPar.Epk.c_str())); |
|||
AddLogString(string_format("modPar.addr_epk size : %d", modPar.AddressEpkList.size())); |
|||
for (int i = 0; i < modPar.AddressEpkList.size(); i++) { |
|||
AddLogString(string_format("modPar.addr_epk (%d) addr (0x%X)", i, modPar.AddressEpkList.at(i))); |
|||
} |
|||
AddLogString(string_format("modPar.memory layout size : %d", modPar.MemoryLayoutList.size())); |
|||
/*
|
|||
for (int i = 0; i < modPar.MemoryLayoutList.size(); i++) { |
|||
AddLogString(string_format("modPar.MemoryLayoutList (%d) addr (0x%X)", i, modPar.MemoryLayoutList.at(i))); |
|||
} |
|||
*/ |
|||
|
|||
AddLogString(string_format("modPar.memory segment size : %d", modPar.MemorySegmentList.size())); |
|||
|
|||
for (int i = 0; i < modPar.MemorySegmentList.size(); i++) { |
|||
AddLogString(string_format("(%d) modPar.Memory sement description=[%s] segment_type=[%d] memory_type=[%d] attribution=[%d] addr (0x%X) size(0x%X) offset_list=[%d] ifDataList=[%d]", |
|||
i, modPar.MemorySegmentList.at(i).Description.c_str(), modPar.MemorySegmentList.at(i).SegmentType, modPar.MemorySegmentList.at(i).MemoryType, |
|||
modPar.MemorySegmentList.at(i).Attribute, modPar.MemorySegmentList.at(i).Address, modPar.MemorySegmentList.at(i).Size, |
|||
modPar.MemorySegmentList.at(i).OffsetList.size(), modPar.MemorySegmentList.at(i).IfDataList.size())); |
|||
|
|||
} |
|||
|
|||
AddLogString(""); |
|||
|
|||
const auto& modComm = module->ModCommon(); |
|||
AddLogString(string_format("modComm.Comment() : %s", modComm.Comment.c_str())); |
|||
AddLogString(string_format("modComm.Deposit : %d", modComm.Deposit)); |
|||
AddLogString(string_format("modComm.ByteOrder : %d", modComm.ByteOrder)); |
|||
AddLogString(string_format("modComm.AlignmentByte : %d", modComm.AlignmentByte)); |
|||
AddLogString(string_format("modComm.AlignmentFloat16 : %d", modComm.AlignmentFloat16)); |
|||
AddLogString(string_format("modComm.AlignmentFloat32 : %d", modComm.AlignmentFloat32)); |
|||
AddLogString(string_format("modComm.AlignmentFloat64 : %d", modComm.AlignmentFloat64)); |
|||
AddLogString(string_format("modComm.AlignmentInt64 : %d", modComm.AlignmentInt64)); |
|||
AddLogString(string_format("modComm.AlignmentLong : %d", modComm.AlignmentLong)); |
|||
AddLogString(string_format("modComm.AlignmentWord : %d", modComm.AlignmentWord)); |
|||
|
|||
AddLogString(""); |
|||
|
|||
for (const auto& [protocol, if_data] : module->IfDatas()) { |
|||
a2l::IfDataBlock block(if_data); |
|||
//EXPECT_TRUE(block.IsOk()) << block.LastError();
|
|||
std::cout << block.AsString() << std::endl; |
|||
|
|||
AddLogString(string_format("IF_DATA : %s", block.Protocol().c_str())); |
|||
AddLogString(string_format("block.ItemList().size() : %d", block.ItemList().size())); |
|||
|
|||
for (int i = 0; i < block.ItemList().size(); i++) { |
|||
AddLogString(string_format("%d block.ItemList() : %s", i, block.ItemList()[i].BlockName.c_str())); |
|||
AddLogString(string_format("block.ItemList()[i].ItemList.size() : %d", block.ItemList()[i].ItemList.size())); |
|||
|
|||
for (int j = 0; j < block.ItemList()[i].ItemList.size(); j++) { |
|||
// check digit
|
|||
bool bIsDigit = true; |
|||
if (j > 0) |
|||
TRACE("asdf"); |
|||
for (int cnt = 0; cnt < block.ItemList()[i].ItemList[j].Value.size(); cnt++) { |
|||
//int value = std::isdigit(block.ItemList()[i].ItemList[j].Value.at(cnt));
|
|||
//int alpha = std::isalpha(block.ItemList()[i].ItemList[j].Value.at(cnt));
|
|||
//TRACE("[%c][%d][%d]\n", block.ItemList()[i].ItemList[j].Value.at(cnt), value, alpha);
|
|||
if (std::isdigit(block.ItemList()[i].ItemList[j].Value.at(cnt)) == 0) |
|||
bIsDigit = false; |
|||
} |
|||
|
|||
if (bIsDigit) |
|||
AddLogString(string_format("%d : Address 0x%X (%d) : %s itemlist=%d", j, atoi(block.ItemList()[i].ItemList[j].Value.c_str()), atoi(block.ItemList()[i].ItemList[j].Value.c_str()), block.ItemList()[i].ItemList[j].BlockName.c_str(), block.ItemList()[i].ItemList[j].ItemList.size())); |
|||
else |
|||
AddLogString(string_format("%d : %s : %s itemlist=%d", j, block.ItemList()[i].ItemList[j].Value.c_str(), block.ItemList()[i].ItemList[j].BlockName.c_str(), block.ItemList()[i].ItemList[j].ItemList.size())); |
|||
|
|||
|
|||
for (int k = 0; k < (block.ItemList()[i].ItemList[j].ItemList.size()); k++) { |
|||
AddLogString(string_format(" %d : %s : %s", k, block.ItemList()[i].ItemList[j].ItemList[k].Value.c_str(), block.ItemList()[i].ItemList[j].ItemList[k].BlockName.c_str())); |
|||
} |
|||
} |
|||
|
|||
AddLogString(""); |
|||
} |
|||
//AddLogString(string_format("block.AsString() : %s", block.AsString().c_str()));
|
|||
|
|||
AddLogString(""); |
|||
} |
|||
|
|||
AddLogString(""); |
|||
const auto& axis_list = module->AxisPtss(); |
|||
//EXPECT_GT(axis_list.size(), 1);
|
|||
std::cout << "\t\tAXIS PTS" << std::endl; |
|||
for (const auto& [pts_name, pts] : axis_list) { |
|||
std::cout << pts_name << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& blob_list = module->Blobs(); |
|||
//EXPECT_GT(blob_list.size(), 0);
|
|||
std::cout << "\t\tBLOB" << std::endl; |
|||
for (const auto& [blob_name, blob] : blob_list) { |
|||
std::cout << blob_name << " " << blob->Address() << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
AddLogString(""); |
|||
|
|||
const auto& characteristic_list = module->Characteristics(); |
|||
//EXPECT_GT(characteristic_list.size(), 0);
|
|||
std::cout << "\t\tCHARACTERISTIC" << std::endl; |
|||
|
|||
AddLogString(string_format("chracteristics : %d", characteristic_list.size())); |
|||
int i = 0; |
|||
for (const auto& [char_name, characteristic] : characteristic_list) { |
|||
std::cout << char_name << " " << characteristic->Description() << std::endl; |
|||
AddLogString(string_format(" %d : %s", i, characteristic->Description().c_str())); |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
AddLogString(""); |
|||
|
|||
const auto& compu_method_list = module->CompuMethods(); |
|||
//EXPECT_GT(compu_method_list.size(), 0);
|
|||
std::cout << "\t\tCOMPU METHOD" << std::endl; |
|||
for (const auto& [method_name, method] : compu_method_list) { |
|||
std::cout << method_name << " " << method->Description() << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& compu_tab_list = module->CompuTabs(); |
|||
//EXPECT_GT(compu_tab_list.size(), 0);
|
|||
std::cout << "\t\tCOMPU TAB" << std::endl; |
|||
for (const auto& [tab_name, tab] : compu_tab_list) { |
|||
std::cout << tab_name << " " << tab->Description() << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& compu_vtab_list = module->CompuVtabs(); |
|||
//EXPECT_GT(compu_vtab_list.size(), 0);
|
|||
std::cout << "\t\tCOMPU VTAB" << std::endl; |
|||
for (const auto& [vtab_name, vtab] : compu_vtab_list) { |
|||
std::cout << vtab_name << " " << vtab->Description() << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& compu_vtab_range_list = module->CompuVtabRanges(); |
|||
//EXPECT_GT(compu_vtab_range_list.size(), 0);
|
|||
std::cout << "\t\tCOMPU VTAB RANGE" << std::endl; |
|||
for (const auto& [range_name, range] : compu_vtab_range_list) { |
|||
std::cout << range_name << " " << range->Description() << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& frame_list = module->Frames(); |
|||
// EXPECT_GT(frame_list.size(), 0); No frames in file
|
|||
std::cout << "\t\tFRAME" << std::endl; |
|||
for (const auto& [frame_name, frame] : frame_list) { |
|||
std::cout << frame_name << " " << frame->Description() << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& func_list = module->Functions(); |
|||
//EXPECT_GT(func_list.size(), 0);
|
|||
std::cout << "\t\tFUNCTION" << std::endl; |
|||
for (const auto& [func_name, func] : func_list) { |
|||
std::cout << func_name << " " << func->Description() << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& group_list = module->Groups(); |
|||
//EXPECT_GT(group_list.size(), 0);
|
|||
std::cout << "\t\tGROUP" << std::endl; |
|||
for (const auto& [group_name, group] : group_list) { |
|||
std::cout << group_name << " " << group->Description() << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& instance_list = module->Instances(); |
|||
//EXPECT_GT(instance_list.size(), 0);
|
|||
std::cout << "\t\tINSTANCE" << std::endl; |
|||
for (const auto& [instance_name, instance] : instance_list) { |
|||
std::cout << instance_name << " " << instance->Description() << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
AddLogString(""); |
|||
|
|||
const auto& meas_list = module->Measurements(); |
|||
//EXPECT_GT(meas_list.size(), 0);
|
|||
std::cout << "\t\tMEASUREMENT" << std::endl; |
|||
|
|||
AddLogString(string_format("measurement : %d", meas_list.size())); |
|||
|
|||
i = 0; |
|||
for (const auto& [meas_name, meas] : meas_list) { |
|||
std::cout << meas_name << " " << meas->Description() << std::endl; |
|||
AddLogString(string_format(" %d : %s", i, meas->Description().c_str())); |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
AddLogString(""); |
|||
|
|||
const auto& rec_list = module->RecordLayouts(); |
|||
//EXPECT_GT(rec_list.size(), 0);
|
|||
std::cout << "\t\tRECORD LAYOUT" << std::endl; |
|||
for (const auto& [rec_name, rec] : rec_list) { |
|||
std::cout << rec_name << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& trans_list = module->Transformers(); |
|||
//EXPECT_GT(trans_list.size(), 0);
|
|||
std::cout << "\t\tTRANSFORMER" << std::endl; |
|||
for (const auto& [trans_name, trans] : trans_list) { |
|||
std::cout << trans_name << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& taxis_list = module->TypedefAxiss(); |
|||
//EXPECT_GT(taxis_list.size(), 0);
|
|||
std::cout << "\t\tTYPEDEF AXIS" << std::endl; |
|||
for (const auto& [taxis_name, taxis] : taxis_list) { |
|||
std::cout << taxis_name << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& tblob_list = module->TypedefBlobs(); |
|||
//EXPECT_GT(tblob_list.size(), 0);
|
|||
std::cout << "\t\tTYPEDEF BLOB" << std::endl; |
|||
for (const auto& [tblob_name, tblob] : tblob_list) { |
|||
std::cout << tblob_name << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& tchar_list = module->TypedefCharacteristics(); |
|||
//EXPECT_GT(tchar_list.size(), 0);
|
|||
std::cout << "\t\tTYPEDEF CHARACTERISTIC" << std::endl; |
|||
for (const auto& [tchar_name, tchar] : tchar_list) { |
|||
std::cout << tchar_name << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
const auto& tmeas_list = module->TypedefMeasurements(); |
|||
//EXPECT_GT(tmeas_list.size(), 0);
|
|||
std::cout << "\t\tTYPEDEF MEASUREMENT" << std::endl; |
|||
for (const auto& [tmeas_name, tmeas] : tmeas_list) { |
|||
std::cout << tmeas_name << std::endl; |
|||
} |
|||
|
|||
std::cout << std::endl; |
|||
const auto& tstruct_list = module->TypedefStructures(); |
|||
//EXPECT_GT(tstruct_list.size(), 0);
|
|||
std::cout << "\t\tTYPEDEF STRUCTURE" << std::endl; |
|||
for (const auto& [tstruct_name, tstruct] : tstruct_list) { |
|||
std::cout << tstruct_name << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
std::cout << std::endl; |
|||
const auto& unit_list = module->Units(); |
|||
//EXPECT_GT(unit_list.size(), 0);
|
|||
std::cout << "\t\tUNIT" << std::endl; |
|||
for (const auto& [unit_name, unit] : unit_list) { |
|||
std::cout << unit_name << std::endl; |
|||
} |
|||
std::cout << std::endl; |
|||
|
|||
a2l::A2mlBlock a2ml_block(module->A2ml()); |
|||
const auto& a2ml = module->A2ml(); |
|||
const auto a2ml_parse = a2ml_block.IsOk(); |
|||
|
|||
//EXPECT_TRUE(a2ml_parse) << a2ml_block.LastError();
|
|||
/*
|
|||
const auto& block_list = a2ml_scanner.BlockList(); |
|||
for (const auto& block : block_list) { |
|||
std::cout << block.AsString() << std::endl; |
|||
} |
|||
*/ |
|||
} |
|||
} |
|||
|
|||
void CIncSourceTestDlgDlg::AddLogString(std::string strMessage) |
|||
{ |
|||
CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST_DATA); |
|||
std::wstring message_w; |
|||
message_w.assign(strMessage.begin(), strMessage.end()); |
|||
|
|||
pListBox->AddString(message_w.c_str()); |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
|
|||
// IncSourceTestDlgDlg.h: 헤더 파일
|
|||
//
|
|||
|
|||
#pragma once |
|||
|
|||
#include <chrono> |
|||
#include <filesystem> |
|||
#include <map> |
|||
#include <string> |
|||
|
|||
#include "a2l/a2lfile.h" |
|||
#include "a2l/a2mlblock.h" |
|||
#include "a2l/ifdatablock.h" |
|||
|
|||
using namespace std::filesystem; |
|||
using namespace std::chrono_literals; |
|||
|
|||
class CIncSourceTestDlgDlgAutoProxy; |
|||
|
|||
|
|||
// CIncSourceTestDlgDlg 대화 상자
|
|||
class CIncSourceTestDlgDlg : public CDialogEx |
|||
{ |
|||
DECLARE_DYNAMIC(CIncSourceTestDlgDlg); |
|||
friend class CIncSourceTestDlgDlgAutoProxy; |
|||
|
|||
// 생성입니다.
|
|||
public: |
|||
CIncSourceTestDlgDlg(CWnd* pParent = nullptr); // 표준 생성자입니다.
|
|||
virtual ~CIncSourceTestDlgDlg(); |
|||
|
|||
// 대화 상자 데이터입니다.
|
|||
#ifdef AFX_DESIGN_TIME |
|||
enum { IDD = IDD_INCSOURCETESTDLG_DIALOG }; |
|||
#endif |
|||
|
|||
protected: |
|||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
|
|||
|
|||
|
|||
// 구현입니다.
|
|||
protected: |
|||
CIncSourceTestDlgDlgAutoProxy* m_pAutoProxy; |
|||
HICON m_hIcon; |
|||
|
|||
BOOL CanExit(); |
|||
|
|||
// 생성된 메시지 맵 함수
|
|||
virtual BOOL OnInitDialog(); |
|||
afx_msg void OnSysCommand(UINT nID, LPARAM lParam); |
|||
afx_msg void OnPaint(); |
|||
afx_msg HCURSOR OnQueryDragIcon(); |
|||
afx_msg void OnClose(); |
|||
virtual void OnOK(); |
|||
virtual void OnCancel(); |
|||
DECLARE_MESSAGE_MAP() |
|||
public: |
|||
afx_msg void OnBnClickedButtonOpen(); |
|||
|
|||
private: |
|||
void loadA2lFile(std::string strFilePath); |
|||
void AddLogString(std::string strMessage); |
|||
}; |
|||
@ -0,0 +1,60 @@ |
|||
#pragma once |
|||
|
|||
#ifndef VC_EXTRALEAN |
|||
#define VC_EXTRALEAN // 거의 사용되지 않는 내용은 Windows 헤더에서 제외합니다.
|
|||
#endif |
|||
|
|||
#include "targetver.h" |
|||
|
|||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 일부 CString 생성자는 명시적으로 선언됩니다.
|
|||
|
|||
// MFC의 공통 부분과 무시 가능한 경고 메시지에 대한 숨기기를 해제합니다.
|
|||
#define _AFX_ALL_WARNINGS |
|||
|
|||
#include <afxwin.h> // MFC 핵심 및 표준 구성 요소입니다. |
|||
#include <afxext.h> // MFC 확장입니다. |
|||
|
|||
|
|||
#include <afxdisp.h> // MFC 자동화 클래스입니다. |
|||
|
|||
|
|||
|
|||
#ifndef _AFX_NO_OLE_SUPPORT |
|||
#include <afxdtctl.h> // Internet Explorer 4 공용 컨트롤에 대한 MFC 지원입니다. |
|||
#endif |
|||
#ifndef _AFX_NO_AFXCMN_SUPPORT |
|||
#include <afxcmn.h> // Windows 공용 컨트롤에 대한 MFC 지원입니다. |
|||
#endif // _AFX_NO_AFXCMN_SUPPORT
|
|||
|
|||
#include <afxcontrolbars.h> // MFC의 리본 및 컨트롤 막대 지원 |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
// 이 매크로는 TRUE를 전달한다는 점을 제외하면 IMPLEMENT_OLECREATE와 동일합니다
|
|||
// 전달하는 점만 제외하면 IMPLEMENT_OLECREATE와 같습니다.
|
|||
// 자동화 컨트롤러에서 요청한 각 자동화 프록시 개체에 대해
|
|||
// 이 응용 프로그램에 대한 별도의 인스턴스가 시작되도록 합니다.
|
|||
#ifndef IMPLEMENT_OLECREATE2 |
|||
#define IMPLEMENT_OLECREATE2(class_name, external_name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ |
|||
AFX_DATADEF COleObjectFactory class_name::factory(class_name::guid, \ |
|||
RUNTIME_CLASS(class_name), TRUE, _T(external_name)); \ |
|||
const AFX_DATADEF GUID class_name::guid = \ |
|||
{ l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }; |
|||
#endif // IMPLEMENT_OLECREATE2
|
|||
|
|||
#ifdef _UNICODE |
|||
#if defined _M_IX86 |
|||
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") |
|||
#elif defined _M_X64 |
|||
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") |
|||
#else |
|||
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") |
|||
#endif |
|||
#endif |
|||
|
|||
|
|||
@ -0,0 +1,253 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <string> |
|||
#include <vector> |
|||
#include <string_view> |
|||
namespace a2l { |
|||
|
|||
using EnumStringList = std::vector<std::string_view>; |
|||
|
|||
enum class A2lAddressType { |
|||
PBYTE, |
|||
PWORD, |
|||
PLONG, |
|||
PLONGLONG, |
|||
DIRECT, |
|||
UNKNOWN |
|||
}; |
|||
A2lAddressType StringToAddressType(const std::string& text); |
|||
std::string_view AddressTypeToString(A2lAddressType type); |
|||
EnumStringList AddressTypeToStringList(); |
|||
|
|||
enum class A2lAxisType { |
|||
CURVE_AXIS, |
|||
COM_AXIS, |
|||
FIX_AXIS, |
|||
RES_AXIS, |
|||
STD_AXIS, |
|||
UNKNOWN |
|||
}; |
|||
A2lAxisType StringToAxisType(const std::string& text); |
|||
std::string_view AxisTypeToString(A2lAxisType type); |
|||
EnumStringList AxisTypeToStringList(); |
|||
|
|||
enum class A2lByteOrder { |
|||
MSB_FIRST, |
|||
MSB_LAST, |
|||
MSB_FIRST_MSW_LAST, |
|||
MSB_LAST_MSW_FIRST, |
|||
UNKNOWN |
|||
}; |
|||
A2lByteOrder StringToByteOrder(const std::string& order); |
|||
std::string_view ByteOrderToString(A2lByteOrder type); |
|||
EnumStringList ByteOrderToStringList(); |
|||
|
|||
enum class A2lCalibrationAccess { |
|||
CALIBRATION, |
|||
NO_CALIBRATION, |
|||
NOT_IN_MCD_SYSTEM, |
|||
OFFLINE_CALIBRATION, |
|||
UNKNOWN |
|||
}; |
|||
A2lCalibrationAccess StringToCalibrationAccess(const std::string& text); |
|||
std::string_view CalibrationAccessToString(A2lCalibrationAccess access); |
|||
EnumStringList CalibrationAccessToStringList(); |
|||
|
|||
enum class A2lCharacteristicType { |
|||
ASCII, |
|||
CURVE, |
|||
MAP, |
|||
CUBOID, |
|||
CUBE_4, |
|||
CUBE_5, |
|||
VAL_BLK, |
|||
VALUE, |
|||
UNKNOWN |
|||
}; |
|||
A2lCharacteristicType StringToCharacteristicType(const std::string& text); |
|||
std::string_view CharacteristicTypeToString(A2lCharacteristicType type); |
|||
EnumStringList CharacteristicTypeToStringList(); |
|||
|
|||
enum class A2lConversionType { |
|||
IDENTICAL, |
|||
FORM, |
|||
LINEAR, |
|||
RAT_FUNC, |
|||
TAB_INP, |
|||
TAB_NOINTP, |
|||
TAB_VERB, |
|||
UNKNOWN |
|||
}; |
|||
A2lConversionType StringToConversionType(const std::string& text); |
|||
std::string_view ConversionTypeToString(A2lConversionType type); |
|||
EnumStringList ConversionTypeToStringList(); |
|||
|
|||
enum class A2lDataType { |
|||
UBYTE, |
|||
SBYTE, |
|||
UWORD, |
|||
SWORD, |
|||
ULONG, |
|||
SLONG, |
|||
A_UINT64, |
|||
A_INT64, |
|||
FLOAT16_IEEE, |
|||
FLOAT32_IEEE, |
|||
FLOAT64_IEEE, |
|||
UNKNOWN |
|||
}; |
|||
|
|||
A2lDataType StringToDataType(const std::string& text); |
|||
std::string_view DataTypeToString(A2lDataType type); |
|||
EnumStringList DataTypeToStringList(); |
|||
|
|||
enum class A2lDeposit { |
|||
A2L_ABSOLUTE, |
|||
A2L_DIFFERENCE, |
|||
UNKNOWN |
|||
}; |
|||
A2lDeposit StringToDeposit(const std::string& mode); |
|||
std::string_view DepositToString(A2lDeposit deposit); |
|||
EnumStringList DepositToStringList(); |
|||
|
|||
enum class A2lEncoding { |
|||
ASCII, ///< 8-bit characters
|
|||
UTF8, |
|||
UTF16, |
|||
UTF32, |
|||
UNKNOWN |
|||
}; |
|||
A2lEncoding StringToEncoding(const std::string& enc); |
|||
std::string_view EncodingToString(A2lEncoding encoding); |
|||
EnumStringList EncodingToStringList(); |
|||
|
|||
|
|||
enum class A2lIndexMode { |
|||
ALTERNATE_CURVES, |
|||
ALTERNATE_WITH_X, |
|||
ALTERNATE_WITH_Y, |
|||
COLUMN_DIR, |
|||
ROW_DIR, |
|||
UNKNOWN |
|||
}; |
|||
A2lIndexMode StringToIndexMode(const std::string& text); |
|||
std::string_view IndexModeToString(A2lIndexMode mode); |
|||
EnumStringList IndexModeToStringList(); |
|||
|
|||
enum class A2lIndexOrder { |
|||
INDEX_INCR, |
|||
INDEX_DECR, |
|||
UNKNOWN |
|||
}; |
|||
A2lIndexOrder StringToIndexOrder(const std::string& text); |
|||
std::string_view IndexOrderToString(A2lIndexOrder order); |
|||
EnumStringList IndexOrderToStringList(); |
|||
|
|||
enum class A2lLayout { |
|||
ROW_DIR, |
|||
COLUMN_DIR, |
|||
UNKNOWN |
|||
}; |
|||
A2lLayout StringToLayout(const std::string& text); |
|||
std::string_view LayoutToString(A2lLayout layout); |
|||
EnumStringList LayoutToStringList(); |
|||
|
|||
enum class A2lMemoryType { |
|||
EEPROM, |
|||
EPROM, |
|||
FLASH, |
|||
RAM, |
|||
ROM, |
|||
REGISTER, |
|||
NOT_IN_ECU, |
|||
UNKNOWN |
|||
}; |
|||
A2lMemoryType StringToMemoryType(const std::string& text); |
|||
std::string_view MemoryTypeToString(A2lMemoryType type); |
|||
EnumStringList MemoryTypeToStringList(); |
|||
|
|||
enum class A2lMemoryAttribute { |
|||
INTERN, |
|||
EXTERN, |
|||
UNKNOWN |
|||
}; |
|||
A2lMemoryAttribute StringToMemoryAttribute(const std::string& text); |
|||
std::string_view MemoryAttributeToString(A2lMemoryAttribute attr); |
|||
EnumStringList MemoryAttributeToStringList(); |
|||
|
|||
enum class A2lMonotony { |
|||
MON_DECREASE, |
|||
MON_INCREASE, |
|||
STRICT_DECREASE, |
|||
STRICT_INCREASE, |
|||
MONOTONOUS, |
|||
STRICT_MON, |
|||
NOT_MON, |
|||
UNKNOWN |
|||
}; |
|||
A2lMonotony StringToMonotony(const std::string& text); |
|||
std::string_view MonotonyToString(A2lMonotony type); |
|||
EnumStringList MonotonyToStringList(); |
|||
|
|||
|
|||
enum class A2lPrgType { |
|||
PRG_CODE, |
|||
PRG_DATA, |
|||
PRG_RESERVED, |
|||
UNKNOWN |
|||
}; |
|||
A2lPrgType StringToPrgType(const std::string& text); |
|||
std::string_view PrgTypeToString(A2lPrgType type); |
|||
EnumStringList PrgTypeToStringList(); |
|||
|
|||
enum class A2lSegmentType { |
|||
CALIBRATION_VARIABLES, |
|||
CODE, |
|||
DATA, |
|||
EXCLUDE_FROM_FLASH, |
|||
OFFLINE_DATA, |
|||
RESERVED, |
|||
SERAM, |
|||
VARIABLES, |
|||
UNKNOWN |
|||
}; |
|||
A2lSegmentType StringToSegmentType(const std::string& text); |
|||
std::string_view SegmentTypeToString(A2lSegmentType type); |
|||
EnumStringList SegmentTypeToStringList(); |
|||
|
|||
enum class A2lTrigger { |
|||
ON_CHANGE, |
|||
ON_USER_REQUEST, |
|||
UNKNOWN |
|||
}; |
|||
A2lTrigger StringToTrigger(const std::string& text); |
|||
std::string_view TriggerToString(A2lTrigger trigger); |
|||
EnumStringList TriggerToStringList(); |
|||
|
|||
|
|||
enum class A2lTypedefType { |
|||
TYPEDEF_AXIS, |
|||
TYPEDEF_BLOB, |
|||
TYPEDEF_CHARACTERISTIC, |
|||
TYPEDEF_MEASUREMENT, |
|||
TYPEDEF_STRUCTURE, |
|||
UNKNOWN |
|||
}; |
|||
A2lTypedefType StringToTypedefType(const std::string& text); |
|||
std::string_view TypedefTypeToString(A2lTypedefType type); |
|||
EnumStringList TypedefTypeToStringList(); |
|||
|
|||
enum class A2lUnitType { |
|||
DERIVED, |
|||
EXTENDED_SI, |
|||
UNKNOWN |
|||
}; |
|||
A2lUnitType StringToUnitType(const std::string& text); |
|||
std::string_view UnitTypeToString(A2lUnitType type); |
|||
EnumStringList UnitTypeToStringList(); |
|||
} // end namespace
|
|||
@ -0,0 +1,69 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
/** \file a2lfile.h
|
|||
* \brief The A2L file object is the main user object. |
|||
*/ |
|||
#pragma once |
|||
#include <memory> |
|||
#include <sstream> |
|||
#include <string> |
|||
|
|||
#include "a2l/a2lproject.h" |
|||
#include "a2l/a2lstructs.h" |
|||
namespace a2l { |
|||
|
|||
|
|||
|
|||
/** \brief Main user object that is an interface against an A2L file.
|
|||
* |
|||
* The A2L file is the only object the user shall create. It handle the parsing |
|||
* of the file. An A2L file defines an ECU and optional hoe it communicate. |
|||
*/ |
|||
class A2lFile { |
|||
public: |
|||
/** \brief Sets the file name. Full path required. */ |
|||
void Filename(const std::string& filename) {filename_ = filename; } |
|||
/** \brief Returns the file name with full path. */ |
|||
[[nodiscard]] const std::string& Filename() const {return filename_; } |
|||
|
|||
/** \brief Returns the File name without path and extension. */ |
|||
[[nodiscard]] std::string Name() const; |
|||
|
|||
/** \brief Returns the last (parser) error text. */ |
|||
[[nodiscard]] const std::string& LastError() const { return last_error_; } |
|||
|
|||
/** \brief Parses the A2L file. Returns true on success. */ |
|||
[[nodiscard]] bool ParseFile(); |
|||
|
|||
[[nodiscard]] Asap2Version& A2lVersion() { return a2l_version_; } |
|||
[[nodiscard]] const Asap2Version& A2lVersion() const { return a2l_version_; } |
|||
|
|||
[[nodiscard]] Asap2Version& A2mlVersion() { return a2ml_version_; } |
|||
[[nodiscard]] const Asap2Version& A2mlVersion() const { |
|||
return a2ml_version_; |
|||
} |
|||
|
|||
[[nodiscard]] A2lProject& Project() { return project_; } |
|||
[[nodiscard]] const A2lProject& Project() const { return project_; } |
|||
|
|||
void IsA2lFile(bool is_a2l_file) { found_ = is_a2l_file; } |
|||
|
|||
[[nodiscard]] bool IsA2lFile() const { return found_; } |
|||
|
|||
void Merge(A2lFile& include_file); |
|||
|
|||
private: |
|||
bool found_ = false; |
|||
std::string filename_; ///< Full path name
|
|||
mutable std::string last_error_; ///< Last error message
|
|||
|
|||
Asap2Version a2l_version_; |
|||
Asap2Version a2ml_version_; |
|||
A2lProject project_; |
|||
|
|||
|
|||
}; |
|||
|
|||
} // namespace dbc
|
|||
@ -0,0 +1,147 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <cstdint> |
|||
#include <string> |
|||
#include <map> |
|||
|
|||
#include "a2l/a2lenums.h" |
|||
#include "a2l/a2lstructs.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
/** \brief if_data strings sorted in protocol order */ |
|||
using IfDataList = std::map<std::string, std::string>; |
|||
|
|||
class A2lObject { |
|||
public: |
|||
virtual ~A2lObject() = default; |
|||
void Name(const std::string& name) { name_ = name; } |
|||
[[nodiscard]] const std::string& Name() const { return name_; } |
|||
|
|||
|
|||
void ByteOrder(A2lByteOrder order) { byte_order_ = order; } |
|||
[[nodiscard]] A2lByteOrder ByteOrder() const { return byte_order_; } |
|||
|
|||
void CalibrationAccess(A2lCalibrationAccess access) { |
|||
calibration_access_ = access; |
|||
} |
|||
[[nodiscard]] A2lCalibrationAccess CalibrationAccess() const { |
|||
return calibration_access_; |
|||
} |
|||
|
|||
void Description(const std::string& description) { |
|||
description_ = description; |
|||
} |
|||
[[nodiscard]] const std::string& Description() const { return description_; } |
|||
|
|||
void Discrete(bool discrete) { discrete_ = discrete; } |
|||
[[nodiscard]] bool Discrete() const { return discrete_; } |
|||
|
|||
void DisplayIdentifier(const std::string& name) { |
|||
display_identifier_ = name; |
|||
} |
|||
[[nodiscard]] const std::string& DisplayIdentifier() const { |
|||
return display_identifier_; |
|||
} |
|||
|
|||
void EcuAddressExtension(int64_t ext) { |
|||
ecu_address_extension_ = ext; |
|||
} |
|||
[[nodiscard]] int64_t EcuAddressExtension() const { |
|||
return ecu_address_extension_; |
|||
} |
|||
|
|||
void ExtendedLimits(const A2lExtendedLimits& limits) { |
|||
extended_limits_ = limits; |
|||
} |
|||
[[nodiscard]] const A2lExtendedLimits& ExtendedLimits() const { |
|||
return extended_limits_; |
|||
} |
|||
|
|||
void Format(const std::string& format) {format_ = format; } |
|||
[[nodiscard]] const std::string& Format() const { return format_; } |
|||
|
|||
void FunctionList(const std::vector<std::string>& list) { |
|||
function_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& FunctionList() const { |
|||
return function_list_; |
|||
} |
|||
|
|||
void GuardRails(bool guard_rails) { guard_rails_ = guard_rails; } |
|||
[[nodiscard]] bool GuardRails() const { return guard_rails_; }; |
|||
|
|||
void MatrixDim(const std::vector<uint64_t>& list) { matrix_dim_ = list; } |
|||
[[nodiscard]] const std::vector<uint64_t>& MatrixDim() const { |
|||
return matrix_dim_; |
|||
} |
|||
|
|||
void MaxRefresh(const A2lMaxRefresh& rate) { max_refresh_ = rate; } |
|||
[[nodiscard]] const A2lMaxRefresh& MaxRefresh() const { return max_refresh_; }; |
|||
|
|||
void ModelLink(const std::string& link) { model_link_ = link; } |
|||
[[nodiscard]] const std::string& ModelLink() const { return model_link_; } |
|||
|
|||
void PhysUnit(const std::string& unit) { phys_unit_ = unit; } |
|||
[[nodiscard]] const std::string& PhysUnit() const { return phys_unit_; } |
|||
|
|||
void ReadOnly(bool read_only) { read_only_ = read_only; } |
|||
[[nodiscard]] bool ReadOnly() const { return read_only_; } |
|||
|
|||
void RefMemorySegment(const std::string& segment) { |
|||
ref_memory_segment_ = segment; |
|||
} |
|||
[[nodiscard]] const std::string& RefMemorySegment() const { |
|||
return ref_memory_segment_; |
|||
} |
|||
void StepSize(double step_size) { step_size_ = step_size; } |
|||
[[nodiscard]] double StepSize() const { return step_size_; } |
|||
|
|||
void SymbolLink(const A2lSymbolLink& symbol) { symbol_link_ = symbol; } |
|||
[[nodiscard]] const A2lSymbolLink& SymbolLink() const { return symbol_link_; } |
|||
|
|||
void AddAnnotation(const A2lAnnotation& annotation); |
|||
[[nodiscard]] AnnotationList& Annotations() { |
|||
return annotation_list_; |
|||
} |
|||
[[nodiscard]] const AnnotationList& Annotations() const { |
|||
return annotation_list_; |
|||
} |
|||
|
|||
void AddIfData(const std::string& input); |
|||
[[nodiscard]] const IfDataList& IfDatas() const { return if_data_list_;} |
|||
[[nodiscard]] bool HaveIfData() const { return !if_data_list_.empty();} |
|||
[[nodiscard]] bool HaveIfData(const std::string_view& protocol) const; |
|||
private: |
|||
std::string name_; |
|||
std::string description_; |
|||
A2lByteOrder byte_order_ = A2lByteOrder::UNKNOWN; |
|||
A2lCalibrationAccess calibration_access_ = A2lCalibrationAccess::UNKNOWN; |
|||
|
|||
bool discrete_ = false; |
|||
std::string display_identifier_; |
|||
int64_t ecu_address_extension_ = 0; |
|||
A2lExtendedLimits extended_limits_ = {}; |
|||
std::string format_; |
|||
std::vector<std::string> function_list_; |
|||
bool guard_rails_ = false; |
|||
std::vector<uint64_t> matrix_dim_; |
|||
A2lMaxRefresh max_refresh_; |
|||
std::string model_link_; |
|||
std::string phys_unit_; |
|||
bool read_only_ = false; |
|||
std::string ref_memory_segment_; |
|||
double step_size_ = 0.0; |
|||
A2lSymbolLink symbol_link_; |
|||
|
|||
IfDataList if_data_list_; |
|||
AnnotationList annotation_list_; |
|||
|
|||
}; |
|||
|
|||
} // end namespace
|
|||
@ -0,0 +1,34 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <map> |
|||
#include <memory> |
|||
#include <string> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
#include "a2l/a2lstructs.h" |
|||
#include "a2l/module.h" |
|||
|
|||
namespace a2l { |
|||
using ModuleList = std::map<std::string, std::unique_ptr<Module>>; |
|||
|
|||
class A2lProject : public A2lObject { |
|||
public: |
|||
[[nodiscard]] A2lHeader& Header() { return header_;} |
|||
[[nodiscard]] const A2lHeader& Header() const { return header_;} |
|||
|
|||
void AddModule(std::unique_ptr<Module>& module ); |
|||
[[nodiscard]] const ModuleList& Modules() const { return module_list_; } |
|||
[[nodiscard]] ModuleList& Modules() { return module_list_; } |
|||
|
|||
private: |
|||
|
|||
A2lHeader header_; |
|||
ModuleList module_list_; |
|||
}; |
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,257 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
#pragma once |
|||
|
|||
#include <cstdint> |
|||
#include <string> |
|||
#include <vector> |
|||
#include <map> |
|||
#include <memory> |
|||
|
|||
#include "a2l/a2lenums.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
struct Asap2Version { |
|||
uint64_t VersionNo = 0; |
|||
uint64_t UpgradeNo = 0; |
|||
void FromString(const std::string& version) { |
|||
// Assume "Version.Upgrade"
|
|||
try { |
|||
const auto dot = version.find('.'); |
|||
if (dot == std::string::npos) { |
|||
VersionNo = std::stoull(version); |
|||
} else { |
|||
VersionNo = std::stoull(version.substr(0, dot)); |
|||
UpgradeNo = std::stoull(version.substr(dot + 1)); |
|||
} |
|||
} catch (const std::exception& ) {} |
|||
} |
|||
}; |
|||
|
|||
struct A2lAnnotation { |
|||
std::string Label; |
|||
std::string Origin; |
|||
std::vector<std::string> Text; |
|||
}; |
|||
using AnnotationList = std::vector<A2lAnnotation>; |
|||
|
|||
struct A2lAxisPts { |
|||
uint64_t Position = 0; |
|||
A2lDataType DataType = A2lDataType::UNKNOWN; |
|||
A2lIndexOrder IndexOrder = A2lIndexOrder::UNKNOWN; |
|||
A2lAddressType AddressType = A2lAddressType::UNKNOWN; |
|||
}; |
|||
|
|||
struct A2lAxisRescale { |
|||
uint64_t Position = 0; |
|||
A2lDataType DataType = A2lDataType::UNKNOWN; |
|||
uint64_t MaxNoRescalePairs = 0; |
|||
A2lIndexOrder IndexOrder = A2lIndexOrder::UNKNOWN; |
|||
A2lAddressType AddressType = A2lAddressType::UNKNOWN; |
|||
}; |
|||
|
|||
struct A2lBitOperation { |
|||
uint64_t LeftShift = 0; |
|||
uint64_t RightShift = 0; |
|||
bool SignExtended = false; |
|||
}; |
|||
|
|||
struct A2lCalibrationHandle { |
|||
std::string Comment; |
|||
std::vector<int64_t> HandleList; |
|||
}; |
|||
|
|||
struct A2lCalibrationMethod { |
|||
std::string Method; |
|||
uint64_t Version = 0; |
|||
std::vector<A2lCalibrationHandle> CalibrationHandleList; |
|||
}; |
|||
|
|||
struct A2lControllerAddress { |
|||
uint64_t Index = 0; |
|||
A2lByteOrder ByteOrder = A2lByteOrder::MSB_LAST; |
|||
uint64_t StartAddress = 0; |
|||
uint64_t Length = 0; |
|||
}; |
|||
using ControllerAddressList = std::vector<A2lControllerAddress>; |
|||
|
|||
struct A2lDependentCharacteristic { |
|||
std::string Formula; |
|||
std::vector<std::string> CharacteristicList; |
|||
}; |
|||
|
|||
struct A2lDistOp { |
|||
uint64_t Position = 0; |
|||
A2lDataType DataType = A2lDataType::UNKNOWN; |
|||
}; |
|||
|
|||
struct A2lExtendedLimits { |
|||
double LowerLimits = 0.0; |
|||
double UpperLimits = 0.0; |
|||
}; |
|||
|
|||
struct A2lFixAxisPar { |
|||
double Offset = 0.0; |
|||
double Shift = 0.0; |
|||
uint64_t NoAxisPoints = 0; |
|||
}; |
|||
|
|||
struct A2lFixAxisParDist { |
|||
double Offset = 0.0; |
|||
double Distance = 0.0; |
|||
uint64_t NoAxisPoints = 0; |
|||
}; |
|||
|
|||
struct A2lFncValue { |
|||
uint64_t Position = 0; |
|||
A2lDataType DataType = A2lDataType::UNKNOWN; |
|||
A2lIndexMode IndexMode = A2lIndexMode::UNKNOWN; |
|||
A2lAddressType AddressType = A2lAddressType::UNKNOWN; |
|||
}; |
|||
|
|||
struct A2lHeader { |
|||
std::string Comment; |
|||
std::string VersionNo; |
|||
std::string ProjectNo; |
|||
}; |
|||
|
|||
struct A2lIdentification { |
|||
uint64_t Position = 0; |
|||
A2lDataType DataType = A2lDataType::UNKNOWN; |
|||
}; |
|||
|
|||
struct A2lLimits { |
|||
double LowerLimit = 0.0; |
|||
double UpperLimit = 0.0; |
|||
}; |
|||
|
|||
struct A2lMaxRefresh { |
|||
uint64_t ScalingUnit = 0; |
|||
uint64_t Rate = 0; |
|||
}; |
|||
|
|||
struct A2lMemoryLayout { |
|||
A2lPrgType Type = A2lPrgType::UNKNOWN; |
|||
uint64_t Address = 0; |
|||
uint64_t Size = 0; |
|||
std::vector<int64_t> OffsetList; |
|||
std::map<std::string, std::string> IfDataList; |
|||
}; |
|||
|
|||
struct A2lMemorySegment { |
|||
std::string Name; |
|||
std::string Description; |
|||
A2lSegmentType SegmentType = A2lSegmentType::UNKNOWN; |
|||
A2lMemoryType MemoryType = A2lMemoryType::UNKNOWN; |
|||
A2lMemoryAttribute Attribute = A2lMemoryAttribute::UNKNOWN; |
|||
uint64_t Address = 0; |
|||
uint64_t Size = 0; |
|||
std::vector<int64_t> OffsetList; |
|||
std::map<std::string, std::string> IfDataList; |
|||
}; |
|||
|
|||
|
|||
struct A2lModCommon { |
|||
std::string Comment; |
|||
uint64_t AlignmentByte = 0; |
|||
uint64_t AlignmentWord = 0; |
|||
uint64_t AlignmentLong = 0; |
|||
uint64_t AlignmentInt64 = 0; |
|||
uint64_t AlignmentFloat16 = 0; |
|||
uint64_t AlignmentFloat32 = 0; |
|||
uint64_t AlignmentFloat64 = 0; |
|||
A2lByteOrder ByteOrder = A2lByteOrder::UNKNOWN; |
|||
uint64_t DataSize = 0; |
|||
A2lDeposit Deposit = A2lDeposit::UNKNOWN; |
|||
}; |
|||
|
|||
struct A2lModPar { |
|||
std::string Comment; |
|||
std::vector<uint64_t> AddressEpkList; |
|||
std::vector<A2lCalibrationMethod> CalibrationMethodList; |
|||
std::string CpuType; |
|||
std::string Customer; |
|||
std::string CustomerNo; |
|||
std::string Ecu; |
|||
int64_t EcuCalibrationOffset = 0; |
|||
std::string Epk; |
|||
std::vector<A2lMemoryLayout> MemoryLayoutList; |
|||
std::vector<A2lMemorySegment> MemorySegmentList; |
|||
uint64_t NoOfInterfaces = 0; |
|||
std::string PhoneNo; |
|||
std::string Supplier; |
|||
std::map<std::string, std::string> SystemConstantList; |
|||
std::string User; |
|||
std::string Version; |
|||
}; |
|||
|
|||
struct A2lSiExponents { |
|||
int64_t Length = 0; |
|||
int64_t Mass = 0; |
|||
int64_t Time = 0; |
|||
int64_t ElectricCurrent = 0; |
|||
int64_t Temperature = 0; |
|||
int64_t AmountOfSubstance = 0; |
|||
int64_t LuminousIntensity = 0; |
|||
|
|||
[[nodiscard]] bool HasExponent() const { |
|||
return Length != 0 || Mass != 0 || Time != 0 || ElectricCurrent != 0 || |
|||
Temperature != 0 || AmountOfSubstance != 0 || LuminousIntensity != 0; |
|||
} |
|||
}; |
|||
|
|||
|
|||
struct A2lStructureComponent { |
|||
std::string Name; |
|||
std::string Typedef; |
|||
uint64_t AddressOffset = 0; |
|||
A2lAddressType AddressType = A2lAddressType::DIRECT; |
|||
A2lLayout Layout = A2lLayout::ROW_DIR; |
|||
std::vector<uint64_t> MatrixDim; |
|||
std::string SymbolTypeLink; |
|||
}; |
|||
using StructureComponentList = std::map<std::string, |
|||
std::unique_ptr<A2lStructureComponent>>; |
|||
|
|||
struct A2lSymbolLink { |
|||
std::string SymbolName; |
|||
int64_t Offset = 0; |
|||
}; |
|||
|
|||
struct A2lUserRight { |
|||
std::string UserLevelId; |
|||
bool ReadOnly = false; |
|||
std::vector<std::vector<std::string>> RefGroupList; |
|||
}; |
|||
using UserRightList = std::map<std::string, std::unique_ptr<A2lUserRight>>; |
|||
|
|||
struct A2lVarCharacteristic { |
|||
std::string Name; |
|||
std::vector<std::string> CriterionNameList; |
|||
std::vector<uint64_t> AddressList; |
|||
}; |
|||
|
|||
struct A2lVarCriterion { |
|||
std::string Name; |
|||
std::string Description; |
|||
std::vector<std::string> ValueList; |
|||
std::string Measurement; |
|||
std::string SelectionCharacteristic; |
|||
}; |
|||
|
|||
struct A2lVariantCoding { |
|||
std::map<std::string, A2lVarCharacteristic> CharacteristicList; |
|||
std::map<std::string, A2lVarCriterion> CriterionList; |
|||
std::vector<std::map<std::string, std::string>> ForbiddenCombList; |
|||
std::string Naming; |
|||
std::string Separator; |
|||
[[nodiscard]] bool HasCoding() const { |
|||
return !CharacteristicList.empty() || !CriterionList.empty() || |
|||
!ForbiddenCombList.empty() || !Naming.empty() || !Separator.empty(); |
|||
} |
|||
}; |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,28 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include "a2l/a2mlobject.h" |
|||
#include <string> |
|||
|
|||
|
|||
namespace a2l { |
|||
|
|||
class A2mlBlock { |
|||
public: |
|||
explicit A2mlBlock(const std::string& a2ml); |
|||
[[nodiscard]] bool IsOk() const { return parse_; } |
|||
[[nodiscard]] const A2mlBlockList& BlockList() const { return block_list_; } |
|||
[[nodiscard]] const std::string& LastError() const { return last_error_; } |
|||
private: |
|||
bool parse_ = false; |
|||
std::string last_error_; |
|||
A2mlBlockList block_list_; |
|||
|
|||
}; |
|||
|
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,90 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <cstdint> |
|||
#include <vector> |
|||
#include <map> |
|||
#include <string> |
|||
|
|||
namespace a2l { |
|||
|
|||
enum class A2mlTypeName : int { |
|||
PREDEFINED, |
|||
STRUCT, |
|||
TAGGED_STRUCT, |
|||
TAGGED_UNION, |
|||
ENUMERATE, |
|||
BLOCK, |
|||
UNKNOWN |
|||
}; |
|||
|
|||
enum class A2mlDataType : int { |
|||
CHAR, |
|||
INT, |
|||
LONG, |
|||
INT64, |
|||
UCHAR, |
|||
UINT, |
|||
UINT64, |
|||
ULONG, |
|||
DOUBLE, |
|||
FLOAT, |
|||
TEXT_ARRAY, |
|||
UNKNOWN |
|||
}; |
|||
|
|||
class A2mlObject; |
|||
using A2mlMemberList = std::vector<A2mlObject>; |
|||
using A2mlEnumerateList = std::map<int64_t, std::string>; |
|||
using A2mlBlockList = A2mlMemberList; |
|||
|
|||
class A2mlObject { |
|||
public: |
|||
A2mlObject() = default; |
|||
|
|||
explicit A2mlObject(A2mlTypeName type); |
|||
|
|||
void Ident(const std::string& ident) { ident_ = ident; } |
|||
[[nodiscard]] const std::string& Ident() const { return ident_; } |
|||
|
|||
void Tag(const std::string& tag) { tag_ = tag; } |
|||
[[nodiscard]] const std::string& Tag() const { return tag_; } |
|||
|
|||
void Type(A2mlTypeName type) { type_ = type; } |
|||
[[nodiscard]] A2mlTypeName Type() const { return type_; } |
|||
[[nodiscard]] std::string_view TypeAsString() const; |
|||
|
|||
void DataType(A2mlDataType type) { data_type_ = type; } |
|||
[[nodiscard]] A2mlDataType DataType() const { return data_type_; } |
|||
[[nodiscard]] std::string_view DataTypeAsString() const; |
|||
|
|||
void MemberList(const A2mlMemberList& list) { member_list_ = list; } |
|||
[[nodiscard]] A2mlMemberList& MemberList() { return member_list_; } |
|||
[[nodiscard]] const A2mlMemberList& MemberList() const { |
|||
return member_list_; |
|||
} |
|||
|
|||
void EnumerateList(const A2mlEnumerateList& list) { enumerate_list_ = list; } |
|||
[[nodiscard]] A2mlEnumerateList& EnumerateList() { return enumerate_list_; } |
|||
[[nodiscard]] const A2mlEnumerateList& EnumerateList() const { |
|||
return enumerate_list_; |
|||
} |
|||
|
|||
[[nodiscard]] std::string AsString() const; |
|||
private: |
|||
|
|||
std::string tag_; |
|||
std::string ident_; |
|||
A2mlMemberList member_list_; |
|||
A2mlEnumerateList enumerate_list_; |
|||
|
|||
A2mlTypeName type_ = A2mlTypeName::UNKNOWN; |
|||
A2mlDataType data_type_ = A2mlDataType::UNKNOWN; |
|||
|
|||
}; |
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,92 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
#include <memory> |
|||
#include <map> |
|||
#include <cstdint> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
#include "a2l/a2lenums.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
|
|||
class AxisPts : public A2lObject { |
|||
public: |
|||
void Address(uint64_t address) { address_ = address; } |
|||
[[nodiscard]] uint64_t Address() const { return address_; } |
|||
|
|||
void InputQuantity(const std::string& quantity) { |
|||
if (quantity != "NO_INPUT_QUANTITY") { |
|||
input_quantity_ = quantity; |
|||
} else { |
|||
input_quantity_.clear(); |
|||
} |
|||
} |
|||
[[nodiscard]] const std::string& InputQuantity() const { |
|||
return input_quantity_; |
|||
} |
|||
|
|||
void RefRecord(const std::string& ref) { |
|||
ref_record_ = ref; |
|||
} |
|||
[[nodiscard]] const std::string& RefRecord() const { |
|||
return ref_record_; |
|||
} |
|||
|
|||
void MaxDiff(double max_diff) { max_diff_ = max_diff; } |
|||
[[nodiscard]] double MaxDiff() const { return max_diff_; } |
|||
|
|||
void Conversion(const std::string& conversion) { |
|||
if (conversion != "NO_COMPU_METHOD") { |
|||
conversion_ = conversion; |
|||
} else { |
|||
conversion_.clear(); |
|||
} |
|||
} |
|||
[[nodiscard]] const std::string& Conversion() const { |
|||
return conversion_; |
|||
} |
|||
|
|||
void MaxAxisPoints(uint64_t nof) { max_axis_points_ = nof; } |
|||
[[nodiscard]] uint64_t MaxAxisPoints() const { return max_axis_points_; } |
|||
|
|||
void LowerLimit(double limit) { lower_limit_ = limit; } |
|||
[[nodiscard]] double LowerLimit() const { return lower_limit_; } |
|||
|
|||
void UpperLimit(double limit) { upper_limit_ = limit; } |
|||
[[nodiscard]] double UpperLimit() const { return upper_limit_; } |
|||
|
|||
void Deposit(A2lDeposit deposit) { |
|||
deposit_ = deposit; |
|||
} |
|||
[[nodiscard]] A2lDeposit Deposit() const { |
|||
return deposit_; |
|||
} |
|||
|
|||
void Monotony(A2lMonotony monotony) { monotony_ = monotony; } |
|||
[[nodiscard]] A2lMonotony Monotony() const { return monotony_; } |
|||
|
|||
|
|||
private: |
|||
uint64_t address_ = 0; |
|||
std::string input_quantity_; |
|||
std::string ref_record_; ///< Named deposit in standard
|
|||
double max_diff_ = 0.0; |
|||
std::string conversion_; |
|||
uint64_t max_axis_points_ = 0; |
|||
double lower_limit_ = 0.0; |
|||
double upper_limit_ = 0.0; |
|||
|
|||
A2lDeposit deposit_ = A2lDeposit::UNKNOWN; |
|||
A2lExtendedLimits extended_limits_; |
|||
A2lMonotony monotony_ = A2lMonotony::UNKNOWN; |
|||
|
|||
}; |
|||
|
|||
using AxisPtsList = std::map<std::string, std::unique_ptr<AxisPts>>; |
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,32 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
#include <cstdint> |
|||
#include <memory> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
|
|||
namespace a2l { |
|||
class Blob : public A2lObject { |
|||
public: |
|||
void Address(uint64_t address) { address_ = address; } |
|||
[[nodiscard]] uint64_t Address() const { return address_; } |
|||
|
|||
void Size(uint64_t size) { size_ = size; } |
|||
[[nodiscard]] uint64_t Size() const { return size_;} |
|||
|
|||
void AddressType(A2lAddressType type) { address_type_ = type; } |
|||
[[nodiscard]] A2lAddressType AddressType() const { return address_type_;} |
|||
|
|||
private: |
|||
uint64_t address_ = 0; |
|||
uint64_t size_ = 0; |
|||
|
|||
A2lAddressType address_type_ = A2lAddressType::UNKNOWN; |
|||
}; |
|||
|
|||
using BlobList = std::map<std::string, std::unique_ptr<Blob>>; |
|||
} // end namespace a2l
|
|||
@ -0,0 +1,105 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
#include <memory> |
|||
#include <cstdint> |
|||
#include <vector> |
|||
#include <map> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
|
|||
#include "a2l/a2lenums.h" |
|||
#include "a2l/axisdescr.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
class Characteristic : public A2lObject { |
|||
public: |
|||
void Address(uint64_t address) { address_ = address; } |
|||
[[nodiscard]] uint64_t Address() const { return address_; } |
|||
|
|||
void BitMask(uint64_t mask) { bit_mask_ = mask; } |
|||
[[nodiscard]] uint64_t BitMask() const { return bit_mask_; } |
|||
|
|||
void ComparisonQuantity(const std::string& quantity) { |
|||
comparison_quantity_ = quantity; |
|||
} |
|||
[[nodiscard]] const std::string& ComparisonQuantity() const { |
|||
return comparison_quantity_; |
|||
} |
|||
|
|||
void Conversion(const std::string& conversion) { conversion_ = conversion; } |
|||
[[nodiscard]] const std::string& Conversion() const { return conversion_; } |
|||
|
|||
void DependentCharacteristic(const A2lDependentCharacteristic& dependent) { |
|||
dependent_characteristic_ = dependent; |
|||
} |
|||
[[nodiscard]] const A2lDependentCharacteristic& DependentCharacteristic() |
|||
const { return dependent_characteristic_; |
|||
} |
|||
|
|||
void Deposit(const std::string& deposit) { deposit_ = deposit; } |
|||
[[nodiscard]] const std::string& Deposit() const { return deposit_; } |
|||
|
|||
void Encoding(A2lEncoding encoding) { encoding_ = encoding; } |
|||
[[nodiscard]] A2lEncoding Encoding() const { return encoding_; } |
|||
|
|||
void MapList(const std::vector<std::string>& list) { map_list_ = list; } |
|||
[[nodiscard]] const std::vector<std::string>& MapList() const { |
|||
return map_list_; |
|||
} |
|||
|
|||
void MaxDiff(double diff) { max_diff_ = diff; } |
|||
[[nodiscard]] double MaxDiff() const { return max_diff_; } |
|||
|
|||
void LowerLimit(double limit) { lower_limit_ = limit; } |
|||
[[nodiscard]] double LowerLimit() const { return lower_limit_; } |
|||
|
|||
void UpperLimit(double limit) { upper_limit_ = limit; } |
|||
[[nodiscard]] double UpperLimit() const { return upper_limit_; } |
|||
|
|||
void Number(uint64_t number) { number_ = number; } |
|||
[[nodiscard]] uint64_t Number() const { return number_; } |
|||
|
|||
void Type(A2lCharacteristicType type) { type_ = type; } |
|||
[[nodiscard]] A2lCharacteristicType Type() const { return type_; } |
|||
|
|||
void VirtualCharacteristic(const A2lDependentCharacteristic& virt) { |
|||
virtual_characteristic_ = virt; |
|||
} |
|||
[[nodiscard]] const A2lDependentCharacteristic& VirtualCharacteristic() |
|||
const { return virtual_characteristic_; |
|||
} |
|||
|
|||
void AddAxisDescr(std::unique_ptr<AxisDescr>& axis_descr); |
|||
[[nodiscard]] AxisDescrList& AxisDescriptions() { |
|||
return axis_descr_list_; |
|||
} |
|||
[[nodiscard]] const AxisDescrList& AxisDescriptions() const { |
|||
return axis_descr_list_; |
|||
} |
|||
|
|||
private: |
|||
A2lCharacteristicType type_ = A2lCharacteristicType::UNKNOWN; |
|||
AxisDescrList axis_descr_list_; |
|||
uint64_t address_ = 0; |
|||
uint64_t bit_mask_ = 0; |
|||
std::string comparison_quantity_; |
|||
std::string conversion_; |
|||
A2lDependentCharacteristic dependent_characteristic_ = {}; |
|||
std::string deposit_; |
|||
A2lEncoding encoding_ = A2lEncoding::ASCII; |
|||
std::vector<std::string> map_list_; |
|||
double max_diff_ = 0; |
|||
double lower_limit_ = 0.0; |
|||
double upper_limit_ = 0.0; |
|||
uint64_t number_ = 0; |
|||
A2lDependentCharacteristic virtual_characteristic_ = {}; |
|||
}; |
|||
|
|||
using CharacteristicList = std::map<std::string, |
|||
std::unique_ptr<Characteristic>>; |
|||
} // end namespace a2l
|
|||
@ -0,0 +1,64 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <memory> |
|||
#include <string> |
|||
#include <vector> |
|||
#include <map> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
#include "a2l/a2lenums.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
class CompuMethod : public A2lObject { |
|||
public: |
|||
void Type(A2lConversionType type) { conversion_type_ = type; } |
|||
[[nodiscard]] A2lConversionType Type() const { return conversion_type_; } |
|||
|
|||
void Coeffs(const std::vector<double>& list) { coeffs_ = list; } |
|||
[[nodiscard]] const std::vector<double>& Coeffs() const { return coeffs_; } |
|||
|
|||
void CoeffsLinear(const std::vector<double>& list) { |
|||
coeffs_linear_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<double>& CoeffsLinear() const { |
|||
return coeffs_linear_; |
|||
} |
|||
|
|||
void CompuTabRef(const std::string& ref) { compu_tab_ref_ = ref; } |
|||
[[nodiscard]] const std::string& CompuTabRef() const { |
|||
return compu_tab_ref_; |
|||
} |
|||
|
|||
void Formula(const std::string& formula) { formula_ = formula; } |
|||
[[nodiscard]] const std::string& Formula() const { return formula_; } |
|||
|
|||
void FormulaInv(const std::string& formula) { formula_inv_ = formula; } |
|||
[[nodiscard]] const std::string& FormulaInv() const { return formula_inv_; } |
|||
|
|||
void RefUnit(const std::string& unit) { ref_unit_ = unit; } |
|||
[[nodiscard]] const std::string& RefUnit() const { return ref_unit_; } |
|||
|
|||
void StatusStringRef(const std::string& ref) { status_string_ref_ = ref; } |
|||
[[nodiscard]] const std::string& StatusStringRef() const { |
|||
return status_string_ref_; |
|||
} |
|||
private: |
|||
A2lConversionType conversion_type_ = A2lConversionType::UNKNOWN; |
|||
std::vector<double> coeffs_; |
|||
std::vector<double> coeffs_linear_; |
|||
std::string compu_tab_ref_; |
|||
std::string formula_; |
|||
std::string formula_inv_; |
|||
std::string ref_unit_; |
|||
std::string status_string_ref_; |
|||
}; |
|||
|
|||
using CompuMethodList = std::map<std::string, std::unique_ptr<CompuMethod>>; |
|||
|
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
#include <map> |
|||
#include <memory> |
|||
#include <string> |
|||
#include <cstdint> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
|
|||
class CompuVtab : public A2lObject { |
|||
public: |
|||
void Type(A2lConversionType type) { conversion_type_ = type; } |
|||
[[nodiscard]] A2lConversionType Type() const { return conversion_type_; } |
|||
|
|||
void Rows(uint64_t rows) { rows_ = rows; } |
|||
[[nodiscard]] uint64_t Rows() const { return rows_; } |
|||
|
|||
void KeyValueList(const std::map<double, std::string>& list) { |
|||
value_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::map<double, std::string>& KeyValueList() const { |
|||
return value_list_; |
|||
} |
|||
|
|||
void DefaultValue(const std::string& value) { default_value_ = value; } |
|||
[[nodiscard]] const std::string& DefaultValue() const { |
|||
return default_value_; |
|||
} |
|||
|
|||
private: |
|||
A2lConversionType conversion_type_ = A2lConversionType::TAB_VERB; |
|||
uint64_t rows_ = 0; |
|||
std::map<double, std::string> value_list_; |
|||
std::string default_value_; |
|||
}; |
|||
|
|||
using CompuVtabList = std::map<std::string, std::unique_ptr<CompuVtab>>; |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,47 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <map> |
|||
#include <memory> |
|||
#include <string> |
|||
#include <cstdint> |
|||
#include <utility> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
|
|||
class CompuVtabRange : public A2lObject { |
|||
public: |
|||
void Rows(uint64_t rows) { rows_ = rows; } |
|||
[[nodiscard]] uint64_t Rows() const { return rows_; } |
|||
|
|||
void KeyValueList(const std::map<std::pair<double, double>, |
|||
std::string>& list) { |
|||
value_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::map<std::pair<double,double>, |
|||
std::string>& KeyValueList() const { |
|||
return value_list_; |
|||
} |
|||
|
|||
void DefaultValue(const std::string& value) { default_value_ = value; } |
|||
[[nodiscard]] const std::string& DefaultValue() const { |
|||
return default_value_; |
|||
} |
|||
|
|||
private: |
|||
uint64_t rows_ = 0; |
|||
std::map<std::pair<double, double>, std::string> value_list_; |
|||
std::string default_value_; |
|||
}; |
|||
|
|||
using CompuVtabRangeList = std::map<std::string, |
|||
std::unique_ptr<CompuVtabRange>>; |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,40 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
#include <map> |
|||
#include <memory> |
|||
#include <string> |
|||
#include <cstdint> |
|||
#include <vector> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
class Frame : public A2lObject { |
|||
public: |
|||
void ScalingUnit(uint64_t scale) { scaling_unit_ = scale; } |
|||
[[nodiscard]] uint64_t ScalingUnit() const { return scaling_unit_; } |
|||
|
|||
void Rate(uint64_t rate) { rate_ = rate; } |
|||
[[nodiscard]] uint64_t Rate() const { return rate_; } |
|||
|
|||
void FrameMeasurement(const std::vector<std::string>& list) { |
|||
frame_measurement_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& FrameMeasurement() const { |
|||
return frame_measurement_list_; |
|||
} |
|||
|
|||
private: |
|||
uint64_t scaling_unit_ = 0; |
|||
uint64_t rate_ = 0; |
|||
std::vector<std::string> frame_measurement_list_; |
|||
}; |
|||
|
|||
using FrameList = std::map<std::string, std::unique_ptr<Frame>>; |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,88 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <map> |
|||
#include <memory> |
|||
#include <string> |
|||
#include <vector> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
class Function : public A2lObject { |
|||
public: |
|||
void ComponentType(const std::string& type) { component_type_ = type; } |
|||
[[nodiscard]] const std::string& ComponentType() const { |
|||
return component_type_; |
|||
} |
|||
|
|||
void PrototypeOf(const std::string& type) { prototype_of_ = type; } |
|||
[[nodiscard]] const std::string& PrototypeOf() const { |
|||
return prototype_of_; |
|||
} |
|||
|
|||
void DefaultCharacteristics(const std::vector<std::string>& list) { |
|||
default_characteristic_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& DefaultCharacteristics() const { |
|||
return default_characteristic_list_; |
|||
} |
|||
|
|||
void Version(const std::string& version) { version_ = version; } |
|||
[[nodiscard]] const std::string& Version() const { return version_; } |
|||
|
|||
void InMeasurements(const std::vector<std::string>& list) { |
|||
in_measurement_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& InMeasurements() const { |
|||
return in_measurement_list_; |
|||
} |
|||
|
|||
void LocMeasurements(const std::vector<std::string>& list) { |
|||
loc_measurement_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& LocMeasurements() const { |
|||
return loc_measurement_list_; |
|||
} |
|||
|
|||
void OutMeasurements(const std::vector<std::string>& list) { |
|||
out_measurement_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& OutMeasurements() const { |
|||
return out_measurement_list_; |
|||
} |
|||
|
|||
void RefCharacteristics(const std::vector<std::string>& list) { |
|||
ref_characteristic_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& RefCharacteristics() const { |
|||
return ref_characteristic_list_; |
|||
} |
|||
|
|||
void SubFunctions(const std::vector<std::string>& list) { |
|||
sub_function_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& SubFunctions() const { |
|||
return sub_function_list_; |
|||
} |
|||
|
|||
private: |
|||
std::string component_type_; |
|||
std::string prototype_of_; |
|||
std::vector<std::string> default_characteristic_list_; |
|||
std::string version_; |
|||
std::vector<std::string> in_measurement_list_; |
|||
std::vector<std::string> loc_measurement_list_; |
|||
std::vector<std::string> out_measurement_list_; |
|||
std::vector<std::string> ref_characteristic_list_; |
|||
std::vector<std::string> sub_function_list_; |
|||
}; |
|||
|
|||
using FuncList = std::map<std::string, std::unique_ptr<Function>>; |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,50 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
#include <map> |
|||
#include <memory> |
|||
#include <string> |
|||
#include <vector> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
class Group : public A2lObject { |
|||
public: |
|||
void Root(bool root) { root_ = root; } |
|||
[[nodiscard]] bool Root() const { return root_; } |
|||
|
|||
void RefCharacteristics(const std::vector<std::string>& list) { |
|||
ref_characteristic_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& RefCharacteristics() const { |
|||
return ref_characteristic_list_; |
|||
} |
|||
|
|||
void RefMeasurements(const std::vector<std::string>& list) { |
|||
ref_measurement_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& RefMeasurements() const { |
|||
return ref_measurement_list_; |
|||
} |
|||
|
|||
void SubGroups(const std::vector<std::string>& list) { |
|||
sub_group_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& SubGroups() const { |
|||
return sub_group_list_; |
|||
} |
|||
private: |
|||
bool root_ = false; |
|||
std::vector<std::string> ref_characteristic_list_; |
|||
std::vector<std::string> ref_measurement_list_; |
|||
std::vector<std::string> sub_group_list_; |
|||
}; |
|||
|
|||
using GroupList = std::map<std::string, std::unique_ptr<Group>>; |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,40 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <string> |
|||
#include <vector> |
|||
|
|||
#include "a2l/ifdataitem.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
|
|||
class IfDataBlock { |
|||
public: |
|||
explicit IfDataBlock(const std::string& ifdata); |
|||
[[nodiscard]] bool IsOk() const { return parse_; } |
|||
|
|||
[[nodiscard]] const std::string& Protocol() const { |
|||
return protocol_; |
|||
} |
|||
[[nodiscard]] const std::vector<IfDataItem>& ItemList() const { |
|||
return item_list_; |
|||
} |
|||
[[nodiscard]] const std::string& LastError() const { return last_error_; } |
|||
|
|||
[[nodiscard]] std::string AsString() const; |
|||
private: |
|||
bool parse_ = false; |
|||
std::string last_error_; |
|||
std::string protocol_; |
|||
std::vector<IfDataItem> item_list_; |
|||
|
|||
[[nodiscard]] std::string AsString(size_t tab_level, |
|||
const IfDataItem& block_item) const; |
|||
}; |
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,20 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
#pragma once |
|||
|
|||
#include <string> |
|||
#include <vector> |
|||
#include <cstdint> |
|||
|
|||
namespace a2l { |
|||
|
|||
struct IfDataItem { |
|||
std::string Value; |
|||
std::string BlockName; |
|||
std::vector<IfDataItem> ItemList; |
|||
}; |
|||
|
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,49 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
#include <map> |
|||
#include <memory> |
|||
#include <string> |
|||
#include <cstdint> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
#include "a2l/overwrite.h" |
|||
|
|||
namespace a2l { |
|||
class Instance : public A2lObject { |
|||
public: |
|||
void RefTypeDef(const std::string& type) { ref_type_def_ = type; } |
|||
[[nodiscard]] const std::string& RefTypeDef() const { |
|||
return ref_type_def_; |
|||
} |
|||
|
|||
void Address(uint64_t address) { address_ = address; } |
|||
[[nodiscard]] uint64_t Address() const { return address_; } |
|||
|
|||
void AddressType(A2lAddressType type) { address_type_ = type; } |
|||
[[nodiscard]] A2lAddressType AddressType() const { return address_type_; } |
|||
|
|||
void Layout(A2lLayout layout) { layout_ = layout; } |
|||
[[nodiscard]] A2lLayout Layout() const { return layout_; } |
|||
|
|||
void AddOverwrite(std::unique_ptr<Overwrite>& overwrite); |
|||
[[nodiscard]] const OverwriteList& Overwrites() const { |
|||
return overwrite_list_; |
|||
} |
|||
void ReadWrite(bool read_write) { read_write_ = read_write; } |
|||
[[nodiscard]] bool ReadWrite() const { return read_write_; } |
|||
private: |
|||
std::string ref_type_def_; |
|||
uint64_t address_ = 0; |
|||
A2lAddressType address_type_ = A2lAddressType::UNKNOWN; |
|||
A2lLayout layout_ = A2lLayout::UNKNOWN; |
|||
OverwriteList overwrite_list_; |
|||
bool read_write_ = false; |
|||
}; |
|||
|
|||
using InstanceList = std::map< std::string, std::unique_ptr<Instance>>; |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,92 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
#include <map> |
|||
#include <memory> |
|||
#include <string> |
|||
#include <cstdint> |
|||
#include <vector> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
|
|||
class Measurement : public A2lObject { |
|||
public: |
|||
void DataType(A2lDataType type) { data_type_ = type; } |
|||
[[nodiscard]] A2lDataType DataType() const { return data_type_; } |
|||
|
|||
void Conversion(const std::string& conversion) { conversion_ = conversion; } |
|||
[[nodiscard]] const std::string& Conversion() const { return conversion_; } |
|||
|
|||
void Resolution(uint64_t resolution) { resolution_ = resolution; } |
|||
[[nodiscard]] uint64_t Resolution() const { return resolution_; } |
|||
|
|||
void Accuracy(double accuracy) { accuracy_ = accuracy; } |
|||
[[nodiscard]] double Accuracy() const { return accuracy_; } |
|||
|
|||
void LowerLimit(double limit) { lower_limit_ = limit; } |
|||
[[nodiscard]] double LowerLimit() const { return lower_limit_; } |
|||
|
|||
void UpperLimit(double limit) { upper_limit_ = limit; } |
|||
[[nodiscard]] double UpperLimit() const { return upper_limit_; } |
|||
|
|||
void AddressType(A2lAddressType type) { address_type_ = type; } |
|||
[[nodiscard]] A2lAddressType AddressType() const { return address_type_; } |
|||
|
|||
void ArraySize(uint64_t size) { array_size_ = size; } |
|||
[[nodiscard]] uint64_t ArraySize() const { return array_size_; } |
|||
|
|||
void BitMask(uint64_t mask) { bit_mask_ = mask; } |
|||
[[nodiscard]] uint64_t BitMask() const { return bit_mask_; } |
|||
|
|||
void BitOperation(const A2lBitOperation& operation) { |
|||
bit_operation_ = operation; |
|||
} |
|||
[[nodiscard]] const A2lBitOperation& BitOperation() const { |
|||
return bit_operation_; |
|||
} |
|||
|
|||
void EcuAddress(uint64_t address) { ecu_address_ = address; } |
|||
[[nodiscard]] uint64_t EcuAddress() const { return ecu_address_; } |
|||
|
|||
void ErrorMask(uint64_t mask) { error_mask_ = mask; } |
|||
[[nodiscard]] uint64_t ErrorMask() const { return error_mask_; } |
|||
|
|||
void Layout(A2lLayout layout) { layout_ = layout; } |
|||
[[nodiscard]] A2lLayout Layout() const { return layout_; } |
|||
|
|||
void ReadWrite(bool read_write) { read_write_ = read_write; } |
|||
[[nodiscard]] bool ReadWrite() const { return read_write_; } |
|||
|
|||
void Virtuals(const std::vector<std::string>& list) { |
|||
virtual_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& Virtuals() const { |
|||
return virtual_list_; |
|||
} |
|||
|
|||
private: |
|||
A2lDataType data_type_ = A2lDataType::UNKNOWN; |
|||
std::string conversion_; |
|||
uint64_t resolution_ = 0; |
|||
double accuracy_ = 0.0; |
|||
double lower_limit_ = 0.0; |
|||
double upper_limit_ = 0.0; |
|||
A2lAddressType address_type_ = A2lAddressType::UNKNOWN; |
|||
uint64_t array_size_ = 0; |
|||
uint64_t bit_mask_ = 0; |
|||
A2lBitOperation bit_operation_ = {}; |
|||
uint64_t ecu_address_ = 0; |
|||
uint64_t error_mask_ = 0; |
|||
A2lLayout layout_ = A2lLayout::UNKNOWN; |
|||
bool read_write_ = false; |
|||
std::vector<std::string> virtual_list_; |
|||
}; |
|||
|
|||
using MeasurementList = std::map<std::string, std::unique_ptr<Measurement>>; |
|||
} |
|||
@ -0,0 +1,258 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
|
|||
#include "a2l/a2lobject.h" |
|||
#include "a2l/a2lstructs.h" |
|||
#include "a2l/axisdescr.h" |
|||
#include "a2l/axispts.h" |
|||
#include "a2l/blob.h" |
|||
#include "a2l/characteristic.h" |
|||
#include "a2l/compumethod.h" |
|||
#include "a2l/computab.h" |
|||
#include "a2l/compuvtab.h" |
|||
#include "a2l/compuvtabrange.h" |
|||
#include "a2l/frame.h" |
|||
#include "a2l/function.h" |
|||
#include "a2l/group.h" |
|||
#include "a2l/instance.h" |
|||
#include "a2l/measurement.h" |
|||
#include "a2l/recordlayout.h" |
|||
#include "a2l/transformer.h" |
|||
#include "a2l/structure.h" |
|||
#include "a2l/unit.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
class Module : public A2lObject { |
|||
public: |
|||
[[nodiscard]] A2lModCommon& ModCommon() { return mod_common_; } |
|||
[[nodiscard]] const A2lModCommon& ModCommon() const { return mod_common_; } |
|||
|
|||
[[nodiscard]] A2lModPar& ModPar() { return mod_par_; } |
|||
[[nodiscard]] const A2lModPar& ModPar() const { return mod_par_; } |
|||
|
|||
[[nodiscard]] A2lVariantCoding& VariantCoding() { return variant_coding_; } |
|||
[[nodiscard]] const A2lVariantCoding& VariantCoding() const { |
|||
return variant_coding_; |
|||
} |
|||
void A2ml(const std::string& a2ml) { a2ml_ = a2ml; } |
|||
[[nodiscard]] const std::string& A2ml() const { return a2ml_;} |
|||
|
|||
void AddAxisPts(std::unique_ptr<AxisPts>& axis_pts); |
|||
[[nodiscard]] AxisPtsList& AxisPtss() { return axis_pts_list_; } |
|||
[[nodiscard]] const AxisPtsList& AxisPtss() const { return axis_pts_list_; } |
|||
[[nodiscard]] AxisPts* GetAxisPts(const std::string& name); |
|||
|
|||
void AddBlob(std::unique_ptr<Blob>& blob); |
|||
[[nodiscard]] BlobList& Blobs() { return blob_list_; } |
|||
[[nodiscard]] const BlobList& Blobs() const { return blob_list_; } |
|||
[[nodiscard]] Blob* GetBlob(const std::string& name); |
|||
|
|||
void AddCharacteristic(std::unique_ptr<Characteristic>& characteristic); |
|||
[[nodiscard]] CharacteristicList& Characteristics() { |
|||
return characteristic_list_; |
|||
} |
|||
[[nodiscard]] const CharacteristicList& Characteristics() const { |
|||
return characteristic_list_; |
|||
} |
|||
[[nodiscard]] Characteristic* GetCharacteristic(const std::string& name); |
|||
|
|||
void AddCompuMethod(std::unique_ptr<CompuMethod>& method); |
|||
[[nodiscard]] CompuMethodList& CompuMethods() { |
|||
return compu_method_list_; |
|||
} |
|||
[[nodiscard]] const CompuMethodList& CompuMethods() const { |
|||
return compu_method_list_; |
|||
} |
|||
|
|||
void AddCompuTab(std::unique_ptr<CompuTab>& tab); |
|||
[[nodiscard]] CompuTabList& CompuTabs() { |
|||
return compu_tab_list_; |
|||
} |
|||
[[nodiscard]] const CompuTabList& CompuTabs() const { |
|||
return compu_tab_list_; |
|||
} |
|||
[[nodiscard]] CompuTab* GetCompuTab(const std::string& name); |
|||
|
|||
void AddCompuVtab(std::unique_ptr<CompuVtab>& tab); |
|||
[[nodiscard]] CompuVtabList& CompuVtabs() { |
|||
return compu_vtab_list_; |
|||
} |
|||
[[nodiscard]] const CompuVtabList& CompuVtabs() const { |
|||
return compu_vtab_list_; |
|||
} |
|||
[[nodiscard]] CompuVtab* GetCompuVtab(const std::string& name); |
|||
|
|||
|
|||
void AddCompuVtabRange(std::unique_ptr<CompuVtabRange>& tab); |
|||
[[nodiscard]] CompuVtabRangeList& CompuVtabRanges() { |
|||
return compu_vtab_range_list_; |
|||
} |
|||
[[nodiscard]] const CompuVtabRangeList& CompuVtabRanges() const { |
|||
return compu_vtab_range_list_; |
|||
} |
|||
[[nodiscard]] CompuVtabRange* GetCompuVtabRange(const std::string& name); |
|||
|
|||
void AddControllerAddress(A2lControllerAddress controller_address) { |
|||
controller_address_list_.emplace_back(controller_address); |
|||
} |
|||
[[nodiscard]] ControllerAddressList& ControllerAddresses() { |
|||
return controller_address_list_; |
|||
} |
|||
[[nodiscard]] const ControllerAddressList& ControllerAddresses() const { |
|||
return controller_address_list_; |
|||
} |
|||
|
|||
void AddFrame(std::unique_ptr<Frame>& frame); |
|||
[[nodiscard]] FrameList& Frames() { |
|||
return frame_list_; |
|||
} |
|||
[[nodiscard]] const FrameList& Frames() const { |
|||
return frame_list_; |
|||
} |
|||
|
|||
void AddFunction(std::unique_ptr<Function>& func); |
|||
[[nodiscard]] FuncList& Functions() { |
|||
return function_list_; |
|||
} |
|||
[[nodiscard]] const FuncList& Functions() const { |
|||
return function_list_; |
|||
} |
|||
|
|||
void AddGroup(std::unique_ptr<Group>& group); |
|||
[[nodiscard]] GroupList& Groups() { |
|||
return group_list_; |
|||
} |
|||
[[nodiscard]] const GroupList& Groups() const { |
|||
return group_list_; |
|||
} |
|||
|
|||
void AddInstance(std::unique_ptr<Instance>& instance); |
|||
[[nodiscard]] InstanceList& Instances() { |
|||
return instance_list_; |
|||
} |
|||
[[nodiscard]] const InstanceList& Instances() const { |
|||
return instance_list_; |
|||
} |
|||
|
|||
void AddMeasurement(std::unique_ptr<Measurement>& measurement); |
|||
[[nodiscard]] MeasurementList& Measurements() { |
|||
return measurement_list_; |
|||
} |
|||
[[nodiscard]] const MeasurementList& Measurements() const { |
|||
return measurement_list_; |
|||
} |
|||
[[nodiscard]] Measurement* GetMeasurement(const std::string& name); |
|||
|
|||
void AddRecordLayout(std::unique_ptr<RecordLayout>& record_layout); |
|||
[[nodiscard]] RecordLayoutList& RecordLayouts() { |
|||
return record_layout_list_; |
|||
} |
|||
[[nodiscard]] const RecordLayoutList& RecordLayouts() const { |
|||
return record_layout_list_; |
|||
} |
|||
|
|||
void AddTransformer(std::unique_ptr<Transformer>& transformer); |
|||
[[nodiscard]] TransformerList& Transformers() { |
|||
return transformer_list_; |
|||
} |
|||
[[nodiscard]] const TransformerList& Transformers() const { |
|||
return transformer_list_; |
|||
} |
|||
|
|||
void AddTypedefAxis(std::unique_ptr<AxisPts>& axis); |
|||
[[nodiscard]] AxisPtsList& TypedefAxiss() { return typedef_axis_list_; } |
|||
[[nodiscard]] const AxisPtsList& TypedefAxiss() const { |
|||
return typedef_axis_list_; |
|||
} |
|||
[[nodiscard]] AxisPts* GetTypedefAxis(const std::string& name); |
|||
|
|||
void AddTypedefBlob(std::unique_ptr<Blob>& blob); |
|||
[[nodiscard]] BlobList& TypedefBlobs() { |
|||
return typedef_blob_list_; |
|||
} |
|||
[[nodiscard]] const BlobList& TypedefBlobs() const { |
|||
return typedef_blob_list_; |
|||
} |
|||
[[nodiscard]] Blob* GetTypedefBlob(const std::string& name); |
|||
|
|||
void AddTypedefCharacteristic(std::unique_ptr<Characteristic>& |
|||
characteristic); |
|||
[[nodiscard]] CharacteristicList& TypedefCharacteristics() { |
|||
return typedef_characteristic_list_; |
|||
} |
|||
[[nodiscard]] const CharacteristicList& TypedefCharacteristics() const { |
|||
return typedef_characteristic_list_; |
|||
} |
|||
[[nodiscard]] Characteristic* GetTypedefCharacteristic(const std::string& |
|||
name); |
|||
|
|||
void AddTypedefMeasurement(std::unique_ptr<Measurement>& measurement); |
|||
[[nodiscard]] const MeasurementList& TypedefMeasurements() const { |
|||
return typedef_measurement_list_; |
|||
} |
|||
[[nodiscard]] MeasurementList& TypedefMeasurements() { |
|||
return typedef_measurement_list_; |
|||
} |
|||
[[nodiscard]] Measurement* GetTypedefMeasurement(const std::string& name); |
|||
|
|||
void AddTypedefStructure(std::unique_ptr<Structure>& structure); |
|||
[[nodiscard]] StructureList& TypedefStructures() { |
|||
return typedef_structure_list_; |
|||
} |
|||
[[nodiscard]] const StructureList& TypedefStructures() const { |
|||
return typedef_structure_list_; |
|||
} |
|||
[[nodiscard]] Structure* GetTypedefStructure(const std::string& name); |
|||
|
|||
void AddUnit(std::unique_ptr<Unit>& unit); |
|||
[[nodiscard]] UnitList& Units() { |
|||
return unit_list_; |
|||
} |
|||
[[nodiscard]] const UnitList& Units() const { |
|||
return unit_list_; |
|||
} |
|||
|
|||
void AddUserRight(std::unique_ptr<A2lUserRight>& user_right); |
|||
[[nodiscard]] UserRightList& UserRights() { |
|||
return user_right_list_; |
|||
} |
|||
[[nodiscard]] const UserRightList& UserRights() const { |
|||
return user_right_list_; |
|||
} |
|||
|
|||
private: |
|||
A2lModCommon mod_common_ = {}; |
|||
A2lModPar mod_par_ = {}; |
|||
A2lVariantCoding variant_coding_ = {}; |
|||
std::string a2ml_; |
|||
AxisPtsList axis_pts_list_; |
|||
BlobList blob_list_; |
|||
CharacteristicList characteristic_list_; |
|||
CompuMethodList compu_method_list_; |
|||
CompuTabList compu_tab_list_; |
|||
CompuVtabList compu_vtab_list_; |
|||
CompuVtabRangeList compu_vtab_range_list_; |
|||
ControllerAddressList controller_address_list_; |
|||
FrameList frame_list_; |
|||
FuncList function_list_; |
|||
GroupList group_list_; |
|||
InstanceList instance_list_; |
|||
MeasurementList measurement_list_; |
|||
RecordLayoutList record_layout_list_; |
|||
TransformerList transformer_list_; |
|||
AxisPtsList typedef_axis_list_; |
|||
BlobList typedef_blob_list_; |
|||
CharacteristicList typedef_characteristic_list_; |
|||
MeasurementList typedef_measurement_list_; |
|||
StructureList typedef_structure_list_; |
|||
UnitList unit_list_; |
|||
UserRightList user_right_list_; |
|||
}; |
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,53 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <memory> |
|||
#include <cstdint> |
|||
#include <string> |
|||
#include <vector> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
class Overwrite : public A2lObject { |
|||
public: |
|||
void AxisNo(uint64_t axis) { axis_no_ = axis; } |
|||
[[nodiscard]] uint64_t AxisNo() const { return axis_no_; } |
|||
|
|||
void Conversion(const std::string& conversion) { conversion_ = conversion; } |
|||
[[nodiscard]] const std::string& Conversion() const { return conversion_; } |
|||
|
|||
void InputQuantity(const std::string& quantity) { |
|||
input_quantity_ = quantity; |
|||
} |
|||
[[nodiscard]] const std::string& InputQuantity() const { |
|||
return input_quantity_; |
|||
} |
|||
|
|||
void LowerLimit(double limit) { lower_limit_ = limit; } |
|||
[[nodiscard]] double LowerLimit() const { return lower_limit_; } |
|||
|
|||
void UpperLimit(double limit) { upper_limit_ = limit; } |
|||
[[nodiscard]] double UpperLimit() const { return upper_limit_; } |
|||
|
|||
void Monotony(A2lMonotony monotony) { monotony_ = monotony; } |
|||
[[nodiscard]] A2lMonotony Monotony() const { return monotony_; } |
|||
|
|||
private: |
|||
uint64_t axis_no_ = 0; |
|||
std::string conversion_; |
|||
std::string input_quantity_; |
|||
double lower_limit_ = 0.0; |
|||
double upper_limit_ = 0.0; |
|||
A2lMonotony monotony_ = A2lMonotony::UNKNOWN; |
|||
|
|||
}; |
|||
|
|||
using OverwriteList = std::vector<std::unique_ptr<Overwrite>>; |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,269 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
#include <map> |
|||
#include <memory> |
|||
#include <string> |
|||
#include <vector> |
|||
#include <cstdint> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
|
|||
class RecordLayout : public A2lObject { |
|||
public: |
|||
void AlignmentByte(uint64_t alignment) { alignment_byte_ = alignment; } |
|||
[[nodiscard]] uint64_t AlignmentByte() const { return alignment_byte_; } |
|||
|
|||
void AlignmentWord(uint64_t alignment) { alignment_word_ = alignment; } |
|||
[[nodiscard]] uint64_t AlignmentWord() const { return alignment_word_; } |
|||
|
|||
void AlignmentLong(uint64_t alignment) { alignment_long_ = alignment; } |
|||
[[nodiscard]] uint64_t AlignmentLong() const { return alignment_long_; } |
|||
|
|||
void AlignmentInt64(uint64_t alignment) { alignment_int64_ = alignment; } |
|||
[[nodiscard]] uint64_t AlignmentInt64() const { return alignment_int64_; } |
|||
|
|||
void AlignmentFloat16(uint64_t alignment) { alignment_float16_ = alignment; } |
|||
[[nodiscard]] uint64_t AlignmentFloat16() const { return alignment_float16_; } |
|||
|
|||
void AlignmentFloat32(uint64_t alignment) { alignment_float32_ = alignment; } |
|||
[[nodiscard]] uint64_t AlignmentFloat32() const { return alignment_float32_; } |
|||
|
|||
void AlignmentFloat64(uint64_t alignment) { alignment_float64_ = alignment; } |
|||
[[nodiscard]] uint64_t AlignmentFloat64() const { return alignment_float64_; } |
|||
|
|||
void AxisPtsX(const A2lAxisPts& pts) { axis_pts_x_ = pts; } |
|||
[[nodiscard]] const A2lAxisPts& AxisPtsX() const { return axis_pts_x_; } |
|||
|
|||
void AxisPtsY(const A2lAxisPts& pts) { axis_pts_y_ = pts; } |
|||
[[nodiscard]] const A2lAxisPts& AxisPtsY() const { return axis_pts_y_; } |
|||
|
|||
void AxisPtsZ(const A2lAxisPts& pts) { axis_pts_z_ = pts; } |
|||
[[nodiscard]] const A2lAxisPts& AxisPtsZ() const { return axis_pts_z_; } |
|||
|
|||
void AxisPts4(const A2lAxisPts& pts) { axis_pts_4_ = pts; } |
|||
[[nodiscard]] const A2lAxisPts& AxisPts4() const { return axis_pts_4_; } |
|||
|
|||
void AxisPts5(const A2lAxisPts& pts) { axis_pts_5_ = pts; } |
|||
[[nodiscard]] const A2lAxisPts& AxisPts5() const { return axis_pts_5_; } |
|||
|
|||
void AxisRescaleX(const A2lAxisRescale& scale) { axis_rescale_x_ = scale; } |
|||
[[nodiscard]] const A2lAxisRescale& AxisRescaleX() const { |
|||
return axis_rescale_x_; |
|||
} |
|||
|
|||
void DistOpX(const A2lDistOp& dist) { dist_op_x_ = dist; } |
|||
[[nodiscard]] const A2lDistOp& DistOpX() const { return dist_op_x_; } |
|||
|
|||
void DistOpY(const A2lDistOp& dist) { dist_op_y_ = dist; } |
|||
[[nodiscard]] const A2lDistOp& DistOpY() const { return dist_op_y_; } |
|||
|
|||
void DistOpZ(const A2lDistOp& dist) { dist_op_z_ = dist; } |
|||
[[nodiscard]] const A2lDistOp& DistOpZ() const { return dist_op_z_; } |
|||
|
|||
void DistOp4(const A2lDistOp& dist) { dist_op_4_ = dist; } |
|||
[[nodiscard]] const A2lDistOp& DistOp4() const { return dist_op_4_; } |
|||
|
|||
void DistOp5(const A2lDistOp& dist) { dist_op_5_ = dist; } |
|||
[[nodiscard]] const A2lDistOp& DistOp5() const { return dist_op_5_; } |
|||
|
|||
void FixNoAxisPtsX(uint64_t pts) { fix_no_axis_pts_x_ = pts; } |
|||
[[nodiscard]] uint64_t FixNoAxisPtsX() const { return fix_no_axis_pts_x_; } |
|||
|
|||
void FixNoAxisPtsY(uint64_t pts) { fix_no_axis_pts_y_ = pts; } |
|||
[[nodiscard]] uint64_t FixNoAxisPtsY() const { return fix_no_axis_pts_y_; } |
|||
|
|||
void FixNoAxisPtsZ(uint64_t pts) { fix_no_axis_pts_z_ = pts; } |
|||
[[nodiscard]] uint64_t FixNoAxisPtsZ() const { return fix_no_axis_pts_z_; } |
|||
|
|||
void FixNoAxisPts4(uint64_t pts) { fix_no_axis_pts_4_ = pts; } |
|||
[[nodiscard]] uint64_t FixNoAxisPts4() const { return fix_no_axis_pts_4_; } |
|||
|
|||
void FixNoAxisPts5(uint64_t pts) { fix_no_axis_pts_5_ = pts; } |
|||
[[nodiscard]] uint64_t FixNoAxisPts5() const { return fix_no_axis_pts_5_; } |
|||
|
|||
void FncValues(const A2lFncValue& fnc ) { fnc_values_ = fnc; } |
|||
[[nodiscard]] const A2lFncValue& FncValues() const { return fnc_values_; } |
|||
|
|||
void Identification(const A2lIdentification& ident ) { |
|||
identification_ = ident; |
|||
} |
|||
[[nodiscard]] const A2lIdentification& Identification() const { |
|||
return identification_; |
|||
} |
|||
|
|||
void NoAxisPtsX(const A2lDistOp& pts) { no_axis_pts_x_ = pts; } |
|||
[[nodiscard]] const A2lDistOp& NoAxisPtsX() const { return no_axis_pts_x_; } |
|||
|
|||
void NoAxisPtsY(const A2lDistOp& pts) { no_axis_pts_y_ = pts; } |
|||
[[nodiscard]] const A2lDistOp& NoAxisPtsY() const { return no_axis_pts_y_; } |
|||
|
|||
void NoAxisPtsZ(const A2lDistOp& pts) { no_axis_pts_z_ = pts; } |
|||
[[nodiscard]] const A2lDistOp& NoAxisPtsZ() const { return no_axis_pts_z_; } |
|||
|
|||
void NoAxisPts4(const A2lDistOp& pts) { no_axis_pts_4_ = pts; } |
|||
[[nodiscard]] const A2lDistOp& NoAxisPts4() const { return no_axis_pts_4_; } |
|||
|
|||
void NoAxisPts5(const A2lDistOp& pts) { no_axis_pts_5_ = pts; } |
|||
[[nodiscard]] const A2lDistOp& NoAxisPts5() const { return no_axis_pts_5_; } |
|||
|
|||
void NoRescaleX(const A2lDistOp& pts) { no_rescale_x_ = pts; } |
|||
[[nodiscard]] const A2lDistOp& NoRescaleX() const { return no_rescale_x_; } |
|||
|
|||
void OffsetX(const A2lDistOp& offset) { offset_x_ = offset; } |
|||
[[nodiscard]] const A2lDistOp& OffsetX() const { return offset_x_; } |
|||
|
|||
void OffsetY(const A2lDistOp& offset) { offset_y_ = offset; } |
|||
[[nodiscard]] const A2lDistOp& OffsetY() const { return offset_y_; } |
|||
|
|||
void OffsetZ(const A2lDistOp& offset) { offset_z_ = offset; } |
|||
[[nodiscard]] const A2lDistOp& OffsetZ() const { return offset_z_; } |
|||
|
|||
void Offset4(const A2lDistOp& offset) { offset_4_ = offset; } |
|||
[[nodiscard]] const A2lDistOp& Offset4() const { return offset_4_; } |
|||
|
|||
void Offset5(const A2lDistOp& offset) { offset_5_ = offset; } |
|||
[[nodiscard]] const A2lDistOp& Offset5() const { return offset_5_; } |
|||
|
|||
void AddReserved(const A2lDistOp& reserved); |
|||
[[nodiscard]] const std::vector<A2lDistOp>& ReservedList() const { |
|||
return reserved_list_; |
|||
} |
|||
|
|||
void RipAddrW(const A2lDistOp& rip) { rip_addr_w_ = rip; } |
|||
[[nodiscard]] const A2lDistOp& RipAddrW() const { return rip_addr_w_; } |
|||
|
|||
void RipAddrX(const A2lDistOp& rip) { rip_addr_x_ = rip; } |
|||
[[nodiscard]] const A2lDistOp& RipAddrX() const { return rip_addr_x_; } |
|||
|
|||
void RipAddrY(const A2lDistOp& rip) { rip_addr_y_ = rip; } |
|||
[[nodiscard]] const A2lDistOp& RipAddrY() const { return rip_addr_y_; } |
|||
|
|||
void RipAddrZ(const A2lDistOp& rip) { rip_addr_z_ = rip; } |
|||
[[nodiscard]] const A2lDistOp& RipAddrZ() const { return rip_addr_z_; } |
|||
|
|||
void RipAddr4(const A2lDistOp& rip) { rip_addr_4_ = rip; } |
|||
[[nodiscard]] const A2lDistOp& RipAddr4() const { return rip_addr_4_; } |
|||
|
|||
void RipAddr5(const A2lDistOp& rip) { rip_addr_5_ = rip; } |
|||
[[nodiscard]] const A2lDistOp& RipAddr5() const { return rip_addr_5_; } |
|||
|
|||
void SrcAddrX(const A2lDistOp& src) { src_addr_x_ = src; } |
|||
[[nodiscard]] const A2lDistOp& SrcAddrX() const { return src_addr_x_; } |
|||
|
|||
void SrcAddrY(const A2lDistOp& src) { src_addr_y_ = src; } |
|||
[[nodiscard]] const A2lDistOp& SrcAddrY() const { return src_addr_y_; } |
|||
|
|||
void SrcAddrZ(const A2lDistOp& src) { src_addr_z_ = src; } |
|||
[[nodiscard]] const A2lDistOp& SrcAddrZ() const { return src_addr_z_; } |
|||
|
|||
void SrcAddr4(const A2lDistOp& src) { src_addr_4_ = src; } |
|||
[[nodiscard]] const A2lDistOp& SrcAddr4() const { return src_addr_4_; } |
|||
|
|||
void SrcAddr5(const A2lDistOp& src) { src_addr_5_ = src; } |
|||
[[nodiscard]] const A2lDistOp& SrcAddr5() const { return src_addr_5_; } |
|||
|
|||
void ShiftOpX(const A2lDistOp& shift) { shift_op_x_ = shift; } |
|||
[[nodiscard]] const A2lDistOp& ShiftOpX() const { return shift_op_x_; } |
|||
|
|||
void ShiftOpY(const A2lDistOp& shift) { shift_op_y_ = shift; } |
|||
[[nodiscard]] const A2lDistOp& ShiftOpY() const { return shift_op_y_; } |
|||
|
|||
void ShiftOpZ(const A2lDistOp& shift) { shift_op_z_ = shift; } |
|||
[[nodiscard]] const A2lDistOp& ShiftOpZ() const { return shift_op_z_; } |
|||
|
|||
void ShiftOp4(const A2lDistOp& shift) { shift_op_4_ = shift; } |
|||
[[nodiscard]] const A2lDistOp& ShiftOp4() const { return shift_op_4_; } |
|||
|
|||
void ShiftOp5(const A2lDistOp& shift) { shift_op_5_ = shift; } |
|||
[[nodiscard]] const A2lDistOp& ShiftOp5() const { return shift_op_5_; } |
|||
|
|||
void StaticAddressOffsets(bool offset) { static_address_offsets_ = offset; } |
|||
[[nodiscard]] bool StaticAddressOffsets() const { |
|||
return static_address_offsets_; |
|||
} |
|||
void StaticRecordLayout(bool layout) { static_record_layout_ = layout; } |
|||
[[nodiscard]] bool StaticRecordLayout() const { |
|||
return static_record_layout_; |
|||
} |
|||
|
|||
private: |
|||
uint64_t alignment_byte_ = 0; |
|||
uint64_t alignment_word_ = 0; |
|||
uint64_t alignment_long_ = 0; |
|||
uint64_t alignment_int64_ = 0; |
|||
uint64_t alignment_float16_ = 0; |
|||
uint64_t alignment_float32_ = 0; |
|||
uint64_t alignment_float64_ = 0; |
|||
|
|||
A2lAxisPts axis_pts_x_ = {}; |
|||
A2lAxisPts axis_pts_y_ = {}; |
|||
A2lAxisPts axis_pts_z_ = {}; |
|||
A2lAxisPts axis_pts_4_ = {}; |
|||
A2lAxisPts axis_pts_5_ = {}; |
|||
|
|||
A2lAxisRescale axis_rescale_x_ = {}; |
|||
|
|||
A2lDistOp dist_op_x_ = {}; |
|||
A2lDistOp dist_op_y_ = {}; |
|||
A2lDistOp dist_op_z_ = {}; |
|||
A2lDistOp dist_op_4_ = {}; |
|||
A2lDistOp dist_op_5_ = {}; |
|||
|
|||
uint64_t fix_no_axis_pts_x_ = 0; |
|||
uint64_t fix_no_axis_pts_y_ = 0; |
|||
uint64_t fix_no_axis_pts_z_ = 0; |
|||
uint64_t fix_no_axis_pts_4_ = 0; |
|||
uint64_t fix_no_axis_pts_5_ = 0; |
|||
|
|||
A2lFncValue fnc_values_ = {}; |
|||
A2lIdentification identification_ = {}; |
|||
|
|||
A2lDistOp no_axis_pts_x_ = {}; |
|||
A2lDistOp no_axis_pts_y_ = {}; |
|||
A2lDistOp no_axis_pts_z_ = {}; |
|||
A2lDistOp no_axis_pts_4_ = {}; |
|||
A2lDistOp no_axis_pts_5_ = {}; |
|||
|
|||
A2lDistOp no_rescale_x_ = {}; |
|||
|
|||
A2lDistOp offset_x_ = {}; |
|||
A2lDistOp offset_y_ = {}; |
|||
A2lDistOp offset_z_ = {}; |
|||
A2lDistOp offset_4_ = {}; |
|||
A2lDistOp offset_5_ = {}; |
|||
|
|||
std::vector<A2lDistOp> reserved_list_; |
|||
|
|||
A2lDistOp rip_addr_w_ = {}; |
|||
A2lDistOp rip_addr_x_ = {}; |
|||
A2lDistOp rip_addr_y_ = {}; |
|||
A2lDistOp rip_addr_z_ = {}; |
|||
A2lDistOp rip_addr_4_ = {}; |
|||
A2lDistOp rip_addr_5_ = {}; |
|||
|
|||
A2lDistOp src_addr_x_ = {}; |
|||
A2lDistOp src_addr_y_ = {}; |
|||
A2lDistOp src_addr_z_ = {}; |
|||
A2lDistOp src_addr_4_ = {}; |
|||
A2lDistOp src_addr_5_ = {}; |
|||
|
|||
A2lDistOp shift_op_x_ = {}; |
|||
A2lDistOp shift_op_y_ = {}; |
|||
A2lDistOp shift_op_z_ = {}; |
|||
A2lDistOp shift_op_4_ = {}; |
|||
A2lDistOp shift_op_5_ = {}; |
|||
|
|||
bool static_address_offsets_ = false; |
|||
bool static_record_layout_ = false; |
|||
}; |
|||
|
|||
using RecordLayoutList = std::map<std::string, std::unique_ptr<RecordLayout>>; |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,51 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
#include <map> |
|||
#include <memory> |
|||
#include <string> |
|||
#include <cstdint> |
|||
#include <utility> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
#include "a2l/a2lstructs.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
class Structure : public A2lObject { |
|||
public: |
|||
void Size(uint64_t size) { size_ = size; } |
|||
[[nodiscard]] uint64_t Size() const { return size_; } |
|||
|
|||
void AddressType(A2lAddressType type) { address_type_ = type; } |
|||
[[nodiscard]] A2lAddressType AddressType() const { return address_type_; } |
|||
|
|||
void ConsistentExchange(bool value) { consistent_exchange_ = value; } |
|||
[[nodiscard]] bool ConsistentExchange() const { return consistent_exchange_; } |
|||
|
|||
void AddStructureComponent(std::unique_ptr<A2lStructureComponent>& |
|||
component) { |
|||
structure_component_list_.emplace(component->Name, std::move(component)); |
|||
} |
|||
[[nodiscard]] const StructureComponentList& StructureComponents() const { |
|||
return structure_component_list_; |
|||
} |
|||
|
|||
void SymbolTypeLink(const std::string& link) { symbol_type_link_ = link; } |
|||
[[nodiscard]] const std::string& SymbolTypeLink() const { |
|||
return symbol_type_link_; } |
|||
|
|||
private: |
|||
uint64_t size_ = 0; |
|||
A2lAddressType address_type_ = A2lAddressType::DIRECT; |
|||
bool consistent_exchange_ = false; |
|||
StructureComponentList structure_component_list_; |
|||
std::string symbol_type_link_; |
|||
|
|||
}; |
|||
|
|||
using StructureList = std::map<std::string, std::unique_ptr<Structure>>; |
|||
} // end namespace
|
|||
@ -0,0 +1,70 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <map> |
|||
#include <memory> |
|||
#include <string> |
|||
#include <cstdint> |
|||
#include <vector> |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
|
|||
class Transformer : public A2lObject { |
|||
public: |
|||
void Version(const std::string& version) { version_ = version; } |
|||
[[nodiscard]] const std::string& Version() const {return version_; } |
|||
|
|||
void Executable32(const std::string& exe) { executable32_ = exe; } |
|||
[[nodiscard]] const std::string& Executable32() const {return executable32_; } |
|||
|
|||
void Executable64(const std::string& exe) { executable64_ = exe; } |
|||
[[nodiscard]] const std::string& Executable64() const {return executable64_; } |
|||
|
|||
void Timeout(uint64_t timeout) { timeout_ = timeout; } |
|||
[[nodiscard]] uint64_t Timeout() const {return timeout_; } |
|||
|
|||
void Trigger(A2lTrigger trigger) { trigger_ = trigger; } |
|||
[[nodiscard]] A2lTrigger Trigger() const { return trigger_; } |
|||
|
|||
void InverseTransformer(const std::string& inverse) { |
|||
inverse_transformer_ = inverse; |
|||
} |
|||
[[nodiscard]] const std::string& InverseTransformer() const { |
|||
return inverse_transformer_; |
|||
} |
|||
|
|||
void TransformerInObjects(const std::vector<std::string>& list) { |
|||
in_object_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& TransformerInObjects() const { |
|||
return in_object_list_; |
|||
} |
|||
|
|||
void TransformerOutObjects(const std::vector<std::string>& list) { |
|||
out_object_list_ = list; |
|||
} |
|||
[[nodiscard]] const std::vector<std::string>& TransformerOutObjects() const { |
|||
return out_object_list_; |
|||
} |
|||
|
|||
private: |
|||
std::string version_; |
|||
std::string executable32_; |
|||
std::string executable64_; |
|||
uint64_t timeout_ = 0; |
|||
A2lTrigger trigger_ = A2lTrigger::UNKNOWN; |
|||
std::string inverse_transformer_; |
|||
std::vector<std::string> in_object_list_; |
|||
std::vector<std::string> out_object_list_; |
|||
}; |
|||
|
|||
using TransformerList = std::map<std::string, std::unique_ptr<Transformer>>; |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,48 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
#include <map> |
|||
#include <memory> |
|||
#include <string> |
|||
|
|||
|
|||
#include "a2l/a2lobject.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
|
|||
class Unit : public A2lObject { |
|||
public: |
|||
void Type(A2lUnitType type) { type_ = type; } |
|||
[[nodiscard]] A2lUnitType Type() const { return type_; } |
|||
|
|||
void RefUnit(const std::string& ref) { ref_unit_ = ref; } |
|||
[[nodiscard]] const std::string& RefUnit() const { return ref_unit_; } |
|||
|
|||
void SiExponents(const A2lSiExponents& exponents) { |
|||
si_exponents_ = exponents; |
|||
} |
|||
[[nodiscard]] const A2lSiExponents& SiExponents() const { |
|||
return si_exponents_; |
|||
} |
|||
|
|||
void Gradient(double gradient) { gradient_ = gradient; } |
|||
[[nodiscard]] double Gradient() const { return gradient_; } |
|||
|
|||
void Offset(double offset) { offset_ = offset; } |
|||
[[nodiscard]] double Offset() const { return offset_; } |
|||
|
|||
private: |
|||
A2lUnitType type_ = A2lUnitType::UNKNOWN; |
|||
std::string ref_unit_; |
|||
A2lSiExponents si_exponents_ = {}; |
|||
double gradient_ = 0.0; |
|||
double offset_ = 0.0; |
|||
}; |
|||
|
|||
using UnitList = std::map<std::string, std::unique_ptr<Unit>>; |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,5 @@ |
|||
// pch.cpp: 미리 컴파일된 헤더에 해당하는 소스 파일
|
|||
|
|||
#include "pch.h" |
|||
|
|||
// 미리 컴파일된 헤더를 사용하는 경우 컴파일이 성공하려면 이 소스 파일이 필요합니다.
|
|||
@ -0,0 +1,13 @@ |
|||
// pch.h: 미리 컴파일된 헤더 파일입니다.
|
|||
// 아래 나열된 파일은 한 번만 컴파일되었으며, 향후 빌드에 대한 빌드 성능을 향상합니다.
|
|||
// 코드 컴파일 및 여러 코드 검색 기능을 포함하여 IntelliSense 성능에도 영향을 미칩니다.
|
|||
// 그러나 여기에 나열된 파일은 빌드 간 업데이트되는 경우 모두 다시 컴파일됩니다.
|
|||
// 여기에 자주 업데이트할 파일을 추가하지 마세요. 그러면 성능이 저하됩니다.
|
|||
|
|||
#ifndef PCH_H |
|||
#define PCH_H |
|||
|
|||
// 여기에 미리 컴파일하려는 헤더 추가
|
|||
#include "framework.h" |
|||
|
|||
#endif //PCH_H
|
|||
|
After Width: | Height: | Size: 66 KiB |
Binary file not shown.
@ -0,0 +1,23 @@ |
|||
//{{NO_DEPENDENCIES}}
|
|||
// Microsoft Visual C++에서 생성한 포함 파일입니다.
|
|||
// IncSourceTestDlg.rc에서 사용되고 있습니다.
|
|||
//
|
|||
#define IDM_ABOUTBOX 0x0010 |
|||
#define IDD_ABOUTBOX 100 |
|||
#define IDP_OLE_INIT_FAILED 100 |
|||
#define IDS_ABOUTBOX 101 |
|||
#define IDD_INCSOURCETESTDLG_DIALOG 102 |
|||
#define IDR_MAINFRAME 128 |
|||
#define IDC_LIST_DATA 1001 |
|||
#define IDC_BUTTON_OPEN 1002 |
|||
|
|||
// Next default values for new objects
|
|||
//
|
|||
#ifdef APSTUDIO_INVOKED |
|||
#ifndef APSTUDIO_READONLY_SYMBOLS |
|||
#define _APS_NEXT_RESOURCE_VALUE 130 |
|||
#define _APS_NEXT_COMMAND_VALUE 32771 |
|||
#define _APS_NEXT_CONTROL_VALUE 1000 |
|||
#define _APS_NEXT_SYMED_VALUE 101 |
|||
#endif |
|||
#endif |
|||
@ -0,0 +1,220 @@ |
|||
// -*-C++-*-
|
|||
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
|
|||
// by flex
|
|||
|
|||
// Copyright (c) 1993 The Regents of the University of California.
|
|||
// All rights reserved.
|
|||
//
|
|||
// This code is derived from software contributed to Berkeley by
|
|||
// Kent Williams and Tom Epperly.
|
|||
//
|
|||
// Redistribution and use in source and binary forms, with or without
|
|||
// modification, are permitted provided that the following conditions
|
|||
// are met:
|
|||
|
|||
// 1. Redistributions of source code must retain the above copyright
|
|||
// notice, this list of conditions and the following disclaimer.
|
|||
// 2. Redistributions in binary form must reproduce the above copyright
|
|||
// notice, this list of conditions and the following disclaimer in the
|
|||
// documentation and/or other materials provided with the distribution.
|
|||
|
|||
// Neither the name of the University nor the names of its contributors
|
|||
// may be used to endorse or promote products derived from this software
|
|||
// without specific prior written permission.
|
|||
|
|||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|||
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|||
// PURPOSE.
|
|||
|
|||
// This file defines FlexLexer, an abstract class which specifies the
|
|||
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
|
|||
// which defines a particular lexer class.
|
|||
//
|
|||
// If you want to create multiple lexer classes, you use the -P flag
|
|||
// to rename each yyFlexLexer to some other xxFlexLexer. You then
|
|||
// include <FlexLexer.h> in your other sources once per lexer class:
|
|||
//
|
|||
// #undef yyFlexLexer
|
|||
// #define yyFlexLexer xxFlexLexer
|
|||
// #include <FlexLexer.h>
|
|||
//
|
|||
// #undef yyFlexLexer
|
|||
// #define yyFlexLexer zzFlexLexer
|
|||
// #include <FlexLexer.h>
|
|||
// ...
|
|||
|
|||
#ifndef __FLEX_LEXER_H |
|||
// Never included before - need to define base class.
|
|||
#define __FLEX_LEXER_H |
|||
|
|||
#include <iostream> |
|||
|
|||
extern "C++" { |
|||
|
|||
struct yy_buffer_state; |
|||
typedef int yy_state_type; |
|||
|
|||
class FlexLexer |
|||
{ |
|||
public: |
|||
virtual ~FlexLexer() { } |
|||
|
|||
const char* YYText() const { return yytext; } |
|||
int YYLeng() const { return yyleng; } |
|||
|
|||
virtual void |
|||
yy_switch_to_buffer( yy_buffer_state* new_buffer ) = 0; |
|||
virtual yy_buffer_state* yy_create_buffer( std::istream* s, int size ) = 0; |
|||
virtual yy_buffer_state* yy_create_buffer( std::istream& s, int size ) = 0; |
|||
virtual void yy_delete_buffer( yy_buffer_state* b ) = 0; |
|||
virtual void yyrestart( std::istream* s ) = 0; |
|||
virtual void yyrestart( std::istream& s ) = 0; |
|||
|
|||
virtual int yylex() = 0; |
|||
|
|||
// Call yylex with new input/output sources.
|
|||
int yylex( std::istream& new_in, std::ostream& new_out ) |
|||
{ |
|||
switch_streams( new_in, new_out ); |
|||
return yylex(); |
|||
} |
|||
|
|||
int yylex( std::istream* new_in, std::ostream* new_out = 0) |
|||
{ |
|||
switch_streams( new_in, new_out ); |
|||
return yylex(); |
|||
} |
|||
|
|||
// Switch to new input/output streams. A nil stream pointer
|
|||
// indicates "keep the current one".
|
|||
virtual void switch_streams( std::istream* new_in, |
|||
std::ostream* new_out ) = 0; |
|||
virtual void switch_streams( std::istream& new_in, |
|||
std::ostream& new_out ) = 0; |
|||
|
|||
int lineno() const { return yylineno; } |
|||
|
|||
int debug() const { return yy_flex_debug; } |
|||
void set_debug( int flag ) { yy_flex_debug = flag; } |
|||
|
|||
protected: |
|||
char* yytext; |
|||
int yyleng; |
|||
int yylineno; // only maintained if you use %option yylineno
|
|||
int yy_flex_debug; // only has effect with -d or "%option debug"
|
|||
}; |
|||
|
|||
} |
|||
#endif // FLEXLEXER_H
|
|||
|
|||
#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce) |
|||
// Either this is the first time through (yyFlexLexerOnce not defined),
|
|||
// or this is a repeated include to define a different flavor of
|
|||
// yyFlexLexer, as discussed in the flex manual.
|
|||
# define yyFlexLexerOnce |
|||
|
|||
extern "C++" { |
|||
|
|||
class yyFlexLexer : public FlexLexer { |
|||
public: |
|||
// arg_yyin and arg_yyout default to the cin and cout, but we
|
|||
// only make that assignment when initializing in yylex().
|
|||
yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout ); |
|||
yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 ); |
|||
private: |
|||
void ctor_common(); |
|||
|
|||
public: |
|||
|
|||
virtual ~yyFlexLexer(); |
|||
|
|||
void yy_switch_to_buffer( yy_buffer_state* new_buffer ); |
|||
yy_buffer_state* yy_create_buffer( std::istream* s, int size ); |
|||
yy_buffer_state* yy_create_buffer( std::istream& s, int size ); |
|||
void yy_delete_buffer( yy_buffer_state* b ); |
|||
void yyrestart( std::istream* s ); |
|||
void yyrestart( std::istream& s ); |
|||
|
|||
void yypush_buffer_state( yy_buffer_state* new_buffer ); |
|||
void yypop_buffer_state(); |
|||
|
|||
virtual int yylex(); |
|||
virtual void switch_streams( std::istream& new_in, std::ostream& new_out ); |
|||
virtual void switch_streams( std::istream* new_in = 0, std::ostream* new_out = 0 ); |
|||
virtual int yywrap(); |
|||
|
|||
protected: |
|||
virtual int LexerInput( char* buf, int max_size ); |
|||
virtual void LexerOutput( const char* buf, int size ); |
|||
virtual void LexerError( const char* msg ); |
|||
|
|||
void yyunput( int c, char* buf_ptr ); |
|||
int yyinput(); |
|||
|
|||
void yy_load_buffer_state(); |
|||
void yy_init_buffer( yy_buffer_state* b, std::istream& s ); |
|||
void yy_flush_buffer( yy_buffer_state* b ); |
|||
|
|||
int yy_start_stack_ptr; |
|||
int yy_start_stack_depth; |
|||
int* yy_start_stack; |
|||
|
|||
void yy_push_state( int new_state ); |
|||
void yy_pop_state(); |
|||
int yy_top_state(); |
|||
|
|||
yy_state_type yy_get_previous_state(); |
|||
yy_state_type yy_try_NUL_trans( yy_state_type current_state ); |
|||
int yy_get_next_buffer(); |
|||
|
|||
std::istream yyin; // input source for default LexerInput
|
|||
std::ostream yyout; // output sink for default LexerOutput
|
|||
|
|||
// yy_hold_char holds the character lost when yytext is formed.
|
|||
char yy_hold_char; |
|||
|
|||
// Number of characters read into yy_ch_buf.
|
|||
int yy_n_chars; |
|||
|
|||
// Points to current character in buffer.
|
|||
char* yy_c_buf_p; |
|||
|
|||
int yy_init; // whether we need to initialize
|
|||
int yy_start; // start state number
|
|||
|
|||
// Flag which is used to allow yywrap()'s to do buffer switches
|
|||
// instead of setting up a fresh yyin. A bit of a hack ...
|
|||
int yy_did_buffer_switch_on_eof; |
|||
|
|||
|
|||
size_t yy_buffer_stack_top; /**< index of top of stack. */ |
|||
size_t yy_buffer_stack_max; /**< capacity of stack. */ |
|||
yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */ |
|||
void yyensure_buffer_stack(void); |
|||
|
|||
// The following are not always needed, but may be depending
|
|||
// on use of certain flex features (like REJECT or yymore()).
|
|||
|
|||
yy_state_type yy_last_accepting_state; |
|||
char* yy_last_accepting_cpos; |
|||
|
|||
yy_state_type* yy_state_buf; |
|||
yy_state_type* yy_state_ptr; |
|||
|
|||
char* yy_full_match; |
|||
int* yy_full_state; |
|||
int yy_full_lp; |
|||
|
|||
int yy_lp; |
|||
int yy_looking_for_trail_begin; |
|||
|
|||
int yy_more_flag; |
|||
int yy_more_len; |
|||
int yy_more_offset; |
|||
int yy_prev_more_offset; |
|||
}; |
|||
|
|||
} |
|||
|
|||
#endif // yyFlexLexer || ! yyFlexLexerOnce
|
|||
@ -0,0 +1,496 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
#include "a2l/a2lenums.h" |
|||
#include <array> |
|||
namespace { |
|||
|
|||
template <typename T, size_t S> |
|||
T StringToEnum(const std::string& text, |
|||
const std::array<std::pair<std::string_view, T>, S>& list) { |
|||
auto type = T::UNKNOWN; |
|||
for (const auto& [idx_text, idx_type] : list) { |
|||
if (idx_text == text) { |
|||
type = idx_type; |
|||
break; |
|||
} |
|||
} |
|||
return type; |
|||
} |
|||
|
|||
template <typename T, size_t S> |
|||
std::string_view EnumToString(T type, |
|||
const std::array<std::pair<std::string_view, T>, S>& list) { |
|||
for (const auto& [idx_text, idx_type] : list) { |
|||
if (idx_type == type) { |
|||
return idx_text; |
|||
} |
|||
} |
|||
return "UNKNOWN"; |
|||
} |
|||
|
|||
template <typename T, size_t S> |
|||
a2l::EnumStringList EnumToStringList( |
|||
const std::array<std::pair<std::string_view, T>, S>& list) { |
|||
a2l::EnumStringList enum_list; |
|||
const auto end_type = T::UNKNOWN; |
|||
for (const auto& [idx_text, idx_type] : list) { |
|||
if (idx_type == end_type) { |
|||
break; |
|||
} |
|||
enum_list.emplace_back(idx_text); |
|||
} |
|||
return enum_list; |
|||
} |
|||
|
|||
} // end namespace
|
|||
|
|||
namespace a2l { |
|||
|
|||
/*------------- ADDRESS TYPE ---------------------------*/ |
|||
using StringAddressType = std::pair<std::string_view, A2lAddressType>; |
|||
constexpr std::array<StringAddressType , 5> kAddressTypeList = { |
|||
StringAddressType("PBYTE", A2lAddressType::PBYTE), |
|||
StringAddressType("PWORD", A2lAddressType::PWORD), |
|||
StringAddressType("PLONG", A2lAddressType::PLONG), |
|||
StringAddressType("PLONGLONG", A2lAddressType::PLONGLONG), |
|||
StringAddressType("DIRECT", A2lAddressType::DIRECT) |
|||
}; |
|||
|
|||
A2lAddressType StringToAddressType(const std::string& text) { |
|||
return StringToEnum<A2lAddressType, 5>(text, kAddressTypeList); |
|||
} |
|||
std::string_view AddressTypeToString(A2lAddressType type) { |
|||
return EnumToString<A2lAddressType, 5>(type, kAddressTypeList); |
|||
} |
|||
|
|||
EnumStringList AddressTypeToStringList() { |
|||
return EnumToStringList<A2lAddressType,5>(kAddressTypeList); |
|||
} |
|||
|
|||
|
|||
/* ----------------AXIS TYPE ------------------------*/ |
|||
using StringAxisType = std::pair<std::string_view, A2lAxisType>; |
|||
constexpr std::array<StringAxisType , 5> kAxisTypeList = { |
|||
StringAxisType("CURVE_AXIS", A2lAxisType::CURVE_AXIS), |
|||
StringAxisType("COM_AXIS", A2lAxisType::COM_AXIS), |
|||
StringAxisType("FIX_AXIS", A2lAxisType::FIX_AXIS), |
|||
StringAxisType("RES_AXIS", A2lAxisType::RES_AXIS), |
|||
StringAxisType("STD_AXIS", A2lAxisType::STD_AXIS) |
|||
}; |
|||
|
|||
A2lAxisType StringToAxisType(const std::string& text) { |
|||
return StringToEnum<A2lAxisType, 5>(text, kAxisTypeList); |
|||
} |
|||
|
|||
std::string_view AxisTypeToString(A2lAxisType type) { |
|||
return EnumToString<A2lAxisType, 5>(type, kAxisTypeList); |
|||
} |
|||
|
|||
EnumStringList AxisTypeToStringList() { |
|||
return EnumToStringList<A2lAxisType,5>(kAxisTypeList); |
|||
} |
|||
|
|||
/*----------------- BYTE ORDER -------------------------*/ |
|||
using StringByteOrder = std::pair<std::string_view, A2lByteOrder>; |
|||
constexpr std::array<StringByteOrder , 4> kByteOrderList = { |
|||
StringByteOrder("MSB_FIRST", A2lByteOrder::MSB_FIRST), |
|||
StringByteOrder("MSB_LAST", A2lByteOrder::MSB_LAST), |
|||
StringByteOrder("MSB_FIRST_MSW_LAST", A2lByteOrder::MSB_FIRST_MSW_LAST), |
|||
StringByteOrder("MSB_LAST_MSW_FIRST", A2lByteOrder::MSB_LAST_MSW_FIRST) |
|||
}; |
|||
|
|||
A2lByteOrder StringToByteOrder(const std::string& text) { |
|||
return StringToEnum<A2lByteOrder,4>(text, kByteOrderList); |
|||
} |
|||
std::string_view ByteOrderToString(A2lByteOrder type) { |
|||
return EnumToString<A2lByteOrder, 4>(type, kByteOrderList); |
|||
} |
|||
|
|||
EnumStringList ByteOrderToStringList() { |
|||
return EnumToStringList<A2lByteOrder,4>(kByteOrderList); |
|||
} |
|||
|
|||
/*--------------- CALIBRATION ACCESS ---------------------*/ |
|||
using StringCalibrationAccess = std::pair<std::string_view, |
|||
A2lCalibrationAccess>; |
|||
constexpr std::array<StringCalibrationAccess , 4> kCalibrationAccessList = { |
|||
StringCalibrationAccess("CALIBRATION", A2lCalibrationAccess::CALIBRATION), |
|||
StringCalibrationAccess("NO_CALIBRATION", |
|||
A2lCalibrationAccess::NO_CALIBRATION), |
|||
StringCalibrationAccess("NOT_IN_MCD_SYSTEM", |
|||
A2lCalibrationAccess::NOT_IN_MCD_SYSTEM), |
|||
StringCalibrationAccess("OFFLINE_CALIBRATION", |
|||
A2lCalibrationAccess::OFFLINE_CALIBRATION) |
|||
}; |
|||
|
|||
A2lCalibrationAccess StringToCalibrationAccess(const std::string& text) { |
|||
return StringToEnum<A2lCalibrationAccess,4>(text, kCalibrationAccessList); |
|||
} |
|||
|
|||
std::string_view CalibrationAccessToString(A2lCalibrationAccess access) { |
|||
return EnumToString<A2lCalibrationAccess, 4>(access, kCalibrationAccessList); |
|||
} |
|||
|
|||
EnumStringList CalibrationAccessToStringList() { |
|||
return EnumToStringList<A2lCalibrationAccess,4>(kCalibrationAccessList); |
|||
} |
|||
|
|||
/*----------------- CHARACTERISTIC TYPE -----------------------------*/ |
|||
using StringCharacteristicType= std::pair<std::string_view, |
|||
A2lCharacteristicType>; |
|||
|
|||
constexpr std::array<StringCharacteristicType , 8> kCharacteristicTypeList = { |
|||
StringCharacteristicType("ASCII", A2lCharacteristicType::ASCII), |
|||
StringCharacteristicType("CURVE", A2lCharacteristicType::CURVE), |
|||
StringCharacteristicType("MAP", A2lCharacteristicType::MAP), |
|||
StringCharacteristicType("CUBOID", A2lCharacteristicType::CUBOID), |
|||
StringCharacteristicType("CUBE_4", A2lCharacteristicType::CUBE_4), |
|||
StringCharacteristicType("CUBE_5", A2lCharacteristicType::CUBE_5), |
|||
StringCharacteristicType("VAL_BLK", A2lCharacteristicType::VAL_BLK), |
|||
StringCharacteristicType("VALUE", A2lCharacteristicType::VALUE), |
|||
}; |
|||
|
|||
A2lCharacteristicType StringToCharacteristicType(const std::string& text) { |
|||
return StringToEnum<A2lCharacteristicType,8>(text, kCharacteristicTypeList); |
|||
} |
|||
|
|||
std::string_view CharacteristicTypeToString(A2lCharacteristicType type) { |
|||
return EnumToString<A2lCharacteristicType, 8>(type, kCharacteristicTypeList); |
|||
} |
|||
|
|||
EnumStringList CharacteristicTypeToStringList() { |
|||
return EnumToStringList<A2lCharacteristicType,8>(kCharacteristicTypeList); |
|||
} |
|||
|
|||
/*---------------------- CONVERSION TYPE ------------------------*/ |
|||
using StringConversionType = std::pair<std::string_view, |
|||
A2lConversionType>; |
|||
|
|||
constexpr std::array<StringConversionType , 7> kConversionTypeList = { |
|||
StringConversionType("IDENTICAL", A2lConversionType::IDENTICAL), |
|||
StringConversionType("FORM", A2lConversionType::FORM), |
|||
StringConversionType("LINEAR", A2lConversionType::LINEAR), |
|||
StringConversionType("RAT_FUNC", A2lConversionType::RAT_FUNC), |
|||
StringConversionType("TAB_INP", A2lConversionType::TAB_INP), |
|||
StringConversionType("TAB_NOINTP", A2lConversionType::TAB_NOINTP), |
|||
StringConversionType("TAB_VERB", A2lConversionType::TAB_VERB), |
|||
}; |
|||
|
|||
A2lConversionType StringToConversionType(const std::string& text) { |
|||
return StringToEnum<A2lConversionType,7>(text, kConversionTypeList); |
|||
} |
|||
|
|||
std::string_view ConversionTypeToString(A2lConversionType type) { |
|||
return EnumToString<A2lConversionType, 7>(type, kConversionTypeList); |
|||
} |
|||
|
|||
EnumStringList ConversionTypeToStringList() { |
|||
return EnumToStringList<A2lConversionType,7>(kConversionTypeList); |
|||
} |
|||
|
|||
/*-------------- DAtA TYPE --------------------------*/ |
|||
using StringDataType = std::pair<std::string_view, |
|||
A2lDataType>; |
|||
|
|||
constexpr std::array<StringDataType, 11> kDataTypeList = { |
|||
StringDataType("UBYTE", A2lDataType::UBYTE), |
|||
StringDataType("SBYTE", A2lDataType::SBYTE), |
|||
StringDataType("UWORD", A2lDataType::UWORD), |
|||
StringDataType("SWORD", A2lDataType::SWORD), |
|||
StringDataType("ULONG", A2lDataType::ULONG), |
|||
StringDataType("SLONG", A2lDataType::SLONG), |
|||
StringDataType("A_UINT64", A2lDataType::A_UINT64), |
|||
StringDataType("A_INT64", A2lDataType::A_INT64), |
|||
StringDataType("FLOAT16_IEEE", A2lDataType::FLOAT16_IEEE), |
|||
StringDataType("FLOAT32_IEEE", A2lDataType::FLOAT32_IEEE), |
|||
StringDataType("FLOAT64_IEEE", A2lDataType::FLOAT64_IEEE), |
|||
}; |
|||
|
|||
A2lDataType StringToDataType(const std::string& text) { |
|||
return StringToEnum<A2lDataType,11>(text, kDataTypeList); |
|||
} |
|||
|
|||
std::string_view DataTypeToString(A2lDataType type) { |
|||
return EnumToString<A2lDataType, 11>(type, kDataTypeList); |
|||
} |
|||
|
|||
EnumStringList DataTypeToStringList() { |
|||
return EnumToStringList<A2lDataType,11>(kDataTypeList); |
|||
} |
|||
|
|||
/*--------------- DEPOSIT ---------------------*/ |
|||
|
|||
using StringDeposit = std::pair<std::string_view, A2lDeposit>; |
|||
constexpr std::array<StringDeposit , 2> kDepositList = { |
|||
StringDeposit("ABSOLUTE", A2lDeposit::A2L_ABSOLUTE), |
|||
StringDeposit("DIFFERENCE", A2lDeposit::A2L_DIFFERENCE) |
|||
}; |
|||
|
|||
A2lDeposit StringToDeposit(const std::string& text) { |
|||
return StringToEnum<A2lDeposit,2>(text, kDepositList); |
|||
} |
|||
|
|||
std::string_view DepositToString(A2lDeposit deposit) { |
|||
return EnumToString<A2lDeposit, 2>(deposit, kDepositList); |
|||
} |
|||
|
|||
EnumStringList DepositToStringList() { |
|||
return EnumToStringList<A2lDeposit,2>(kDepositList); |
|||
} |
|||
|
|||
/*----------------- ENCODING ---------------------------*/ |
|||
using StringEncoding = std::pair<std::string_view, A2lEncoding>; |
|||
constexpr std::array<StringEncoding, 4> kEncodingList = { |
|||
StringEncoding("", A2lEncoding::ASCII), |
|||
StringEncoding("UTF8", A2lEncoding::UTF8), |
|||
StringEncoding("UTF16", A2lEncoding::UTF16), |
|||
StringEncoding("UTF32", A2lEncoding::UTF32) |
|||
}; |
|||
|
|||
A2lEncoding StringToEncoding(const std::string& text) { |
|||
return StringToEnum<A2lEncoding,4>(text, kEncodingList); |
|||
} |
|||
|
|||
std::string_view EncodingToString(A2lEncoding encoding) { |
|||
return EnumToString<A2lEncoding, 4>(encoding, kEncodingList); |
|||
} |
|||
|
|||
EnumStringList EncodingToStringList() { |
|||
return EnumToStringList<A2lEncoding,4>(kEncodingList); |
|||
} |
|||
|
|||
/*----------------------- INDEX MODE --------------------*/ |
|||
|
|||
using StringIndexMode = std::pair<std::string_view, A2lIndexMode>; |
|||
constexpr std::array<StringIndexMode , 5> kIndexModeList = { |
|||
StringIndexMode("ALTERNATE_CURVES", A2lIndexMode::ALTERNATE_CURVES), |
|||
StringIndexMode("ALTERNATE_WITH_X", A2lIndexMode::ALTERNATE_WITH_X), |
|||
StringIndexMode("ALTERNATE_WITH_Y", A2lIndexMode::ALTERNATE_WITH_Y), |
|||
StringIndexMode("COLUMN_DIR", A2lIndexMode::COLUMN_DIR), |
|||
StringIndexMode("ROW_DIR", A2lIndexMode::ROW_DIR) |
|||
}; |
|||
|
|||
A2lIndexMode StringToIndexMode(const std::string& text) { |
|||
return StringToEnum<A2lIndexMode,5>(text, kIndexModeList); |
|||
} |
|||
|
|||
std::string_view IndexModeToString(A2lIndexMode mode) { |
|||
return EnumToString<A2lIndexMode, 5>(mode, kIndexModeList); |
|||
} |
|||
|
|||
EnumStringList IndexModeToStringList() { |
|||
return EnumToStringList<A2lIndexMode,5>(kIndexModeList); |
|||
} |
|||
|
|||
/*----------------- INDEX ORDER --------------------------*/ |
|||
|
|||
using StringIndexOrder = std::pair<std::string_view, A2lIndexOrder>; |
|||
constexpr std::array<StringIndexOrder , 2> kIndexOrderList = { |
|||
StringIndexOrder("INDEX_INCR", A2lIndexOrder::INDEX_INCR), |
|||
StringIndexOrder("INDEX_DECR", A2lIndexOrder::INDEX_DECR) |
|||
}; |
|||
|
|||
A2lIndexOrder StringToIndexOrder(const std::string& text) { |
|||
return StringToEnum<A2lIndexOrder,2>(text, kIndexOrderList); |
|||
} |
|||
|
|||
std::string_view IndexOrderToString(A2lIndexOrder order) { |
|||
return EnumToString<A2lIndexOrder, 2>(order, kIndexOrderList); |
|||
} |
|||
|
|||
EnumStringList IndexOrderToStringList() { |
|||
return EnumToStringList<A2lIndexOrder,2>(kIndexOrderList); |
|||
} |
|||
|
|||
/*------------------ LAYOUT -----------------------------*/ |
|||
using StringLayout = std::pair<std::string_view, A2lLayout>; |
|||
constexpr std::array<StringLayout , 2> kLayoutList = { |
|||
StringLayout("ROW_DIR", A2lLayout::ROW_DIR), |
|||
StringLayout("COLUMN_DIR", A2lLayout::COLUMN_DIR) |
|||
}; |
|||
|
|||
A2lLayout StringToLayout(const std::string& text) { |
|||
return StringToEnum<A2lLayout,2>(text, kLayoutList); |
|||
} |
|||
|
|||
std::string_view LayoutToString(A2lLayout layout) { |
|||
return EnumToString<A2lLayout, 2>(layout, kLayoutList); |
|||
} |
|||
|
|||
EnumStringList LayoutToStringList() { |
|||
return EnumToStringList<A2lLayout,2>(kLayoutList); |
|||
} |
|||
|
|||
/*------------------- MEMORY TYPE ------------------------*/ |
|||
using StringMemoryType = std::pair<std::string_view, A2lMemoryType>; |
|||
constexpr std::array<StringMemoryType, 7> kMemoryList = { |
|||
StringMemoryType("EEPROM", A2lMemoryType::EEPROM), |
|||
StringMemoryType("EPROM", A2lMemoryType::EPROM), |
|||
StringMemoryType("FLASH", A2lMemoryType::FLASH), |
|||
StringMemoryType("RAM", A2lMemoryType::RAM), |
|||
StringMemoryType("ROM", A2lMemoryType::ROM), |
|||
StringMemoryType("REGISTER", A2lMemoryType::REGISTER), |
|||
StringMemoryType("NOT_IN_ECU", A2lMemoryType::NOT_IN_ECU), |
|||
}; |
|||
|
|||
A2lMemoryType StringToMemoryType(const std::string& text) { |
|||
return StringToEnum<A2lMemoryType,7>(text, kMemoryList); |
|||
} |
|||
|
|||
std::string_view MemoryTypeToString(A2lMemoryType type) { |
|||
return EnumToString<A2lMemoryType, 7>(type, kMemoryList); |
|||
} |
|||
|
|||
EnumStringList MemoryTypeToStringList() { |
|||
return EnumToStringList<A2lMemoryType,7>(kMemoryList); |
|||
} |
|||
|
|||
|
|||
/*------------ MEMORY ATTRIBUTE -------------------------*/ |
|||
using StringMemoryAttribute = std::pair<std::string_view, A2lMemoryAttribute>; |
|||
constexpr std::array<StringMemoryAttribute, 2> kAttributeList = { |
|||
StringMemoryAttribute("INTERN", A2lMemoryAttribute::INTERN), |
|||
StringMemoryAttribute("EXTERN", A2lMemoryAttribute::EXTERN), |
|||
}; |
|||
|
|||
A2lMemoryAttribute StringToMemoryAttribute(const std::string& text) { |
|||
return StringToEnum<A2lMemoryAttribute,2>(text, kAttributeList); |
|||
} |
|||
std::string_view MemoryAttributeToString(A2lMemoryAttribute attr) { |
|||
return EnumToString<A2lMemoryAttribute, 2>(attr, kAttributeList); |
|||
} |
|||
|
|||
EnumStringList MemoryAttributeToStringList() { |
|||
return EnumToStringList<A2lMemoryAttribute,2>(kAttributeList); |
|||
} |
|||
|
|||
/*-------------------------- MONOTONY -------------------------*/ |
|||
using StringMonotony = std::pair<std::string_view, A2lMonotony>; |
|||
constexpr std::array<StringMonotony, 7> kMonotonyList = { |
|||
StringMonotony("MON_DECREASE", A2lMonotony::MON_DECREASE), |
|||
StringMonotony("MON_INCREASE", A2lMonotony::MON_INCREASE), |
|||
StringMonotony("STRICT_DECREASE", A2lMonotony::STRICT_DECREASE), |
|||
StringMonotony("STRICT_INCREASE", A2lMonotony::STRICT_INCREASE), |
|||
StringMonotony("MONOTONOUS", A2lMonotony::MONOTONOUS), |
|||
StringMonotony("STRICT_MON", A2lMonotony::STRICT_MON), |
|||
StringMonotony("NOT_MON", A2lMonotony::NOT_MON), |
|||
}; |
|||
A2lMonotony StringToMonotony(const std::string& text) { |
|||
return StringToEnum<A2lMonotony,7>(text, kMonotonyList); |
|||
} |
|||
std::string_view MonotonyToString(A2lMonotony type) { |
|||
return EnumToString<A2lMonotony, 7>(type, kMonotonyList); |
|||
} |
|||
|
|||
EnumStringList MonotonyToStringList() { |
|||
return EnumToStringList<A2lMonotony,7>(kMonotonyList); |
|||
} |
|||
|
|||
/*------------------ PRG TYPE -----------------------------*/ |
|||
using StringPrgType = std::pair<std::string_view, A2lPrgType>; |
|||
constexpr std::array<StringPrgType, 3> kPrgList = { |
|||
std::pair("PRG_CODE", A2lPrgType::PRG_CODE), |
|||
std::pair("PRG_DATA", A2lPrgType::PRG_DATA), |
|||
std::pair("PRG_RESERVED", A2lPrgType::PRG_RESERVED), |
|||
}; |
|||
|
|||
A2lPrgType StringToPrgType(const std::string& text) { |
|||
return StringToEnum<A2lPrgType, 3>(text, kPrgList); |
|||
} |
|||
|
|||
std::string_view PrgTypeToString(A2lPrgType type) { |
|||
return EnumToString<A2lPrgType, 3>(type, kPrgList); |
|||
} |
|||
|
|||
EnumStringList PrgTypeToStringList() { |
|||
return EnumToStringList<A2lPrgType,3>(kPrgList); |
|||
} |
|||
|
|||
/*----------------- SEGMENT TYPE -----------------------*/ |
|||
using StringSegmentType = std::pair<std::string_view, A2lSegmentType>; |
|||
constexpr std::array<StringSegmentType, 8> kSegmentList = { |
|||
std::pair("CALIBRATION_VARIABLES", A2lSegmentType::CALIBRATION_VARIABLES), |
|||
std::pair("CODE", A2lSegmentType::CODE), |
|||
std::pair("DATA", A2lSegmentType::DATA), |
|||
std::pair("EXCLUDE_FROM_FLASH", A2lSegmentType::EXCLUDE_FROM_FLASH), |
|||
std::pair("OFFLINE_DATA", A2lSegmentType::OFFLINE_DATA), |
|||
std::pair("RESERVED", A2lSegmentType::RESERVED), |
|||
std::pair("SERAM", A2lSegmentType::SERAM), |
|||
std::pair("VARIABLES", A2lSegmentType::VARIABLES), |
|||
}; |
|||
|
|||
A2lSegmentType StringToSegmentType(const std::string& text) { |
|||
return StringToEnum<A2lSegmentType, 8>(text, kSegmentList); |
|||
} |
|||
|
|||
std::string_view SegmentTypeToString(A2lSegmentType type) { |
|||
return EnumToString<A2lSegmentType, 8>(type, kSegmentList); |
|||
} |
|||
|
|||
EnumStringList SegmentTypeToStringList() { |
|||
return EnumToStringList<A2lSegmentType,8>(kSegmentList); |
|||
} |
|||
|
|||
/*------------------- TRIGGER ------------------------------*/ |
|||
using StringTrigger = std::pair<std::string_view, A2lTrigger>; |
|||
constexpr std::array<StringTrigger, 2> kTriggerList = { |
|||
std::pair("ON_CHANGE", A2lTrigger::ON_CHANGE), |
|||
std::pair("ON_USER_REQUEST", A2lTrigger::ON_USER_REQUEST), |
|||
}; |
|||
|
|||
A2lTrigger StringToTrigger(const std::string& text) { |
|||
return StringToEnum<A2lTrigger, 2>(text, kTriggerList); |
|||
} |
|||
|
|||
std::string_view TriggerToString(A2lTrigger trigger) { |
|||
return EnumToString<A2lTrigger, 2>(trigger, kTriggerList); |
|||
} |
|||
|
|||
EnumStringList TriggerToStringList() { |
|||
return EnumToStringList<A2lTrigger,2>(kTriggerList); |
|||
} |
|||
|
|||
/*------------------ TYPEDEF TYPE ---------------------*/ |
|||
using StringTypedef = std::pair<std::string_view, A2lTypedefType>; |
|||
constexpr std::array<StringTypedef, 5> kTypedefList = { |
|||
std::pair("TYPEDEF_AXIS", A2lTypedefType::TYPEDEF_AXIS), |
|||
std::pair("TYPEDEF_BLOB", A2lTypedefType::TYPEDEF_BLOB), |
|||
std::pair("TYPEDEF_CHARACTERISTIC", A2lTypedefType::TYPEDEF_CHARACTERISTIC), |
|||
std::pair("TYPEDEF_MEASUREMENT", A2lTypedefType::TYPEDEF_MEASUREMENT), |
|||
std::pair("TYPEDEF_STRUCTURE", A2lTypedefType::TYPEDEF_STRUCTURE), |
|||
}; |
|||
|
|||
A2lTypedefType StringToTypedefType(const std::string& text) { |
|||
return StringToEnum<A2lTypedefType, 5>(text, kTypedefList); |
|||
} |
|||
|
|||
std::string_view TypedefTypeToString(A2lTypedefType type) { |
|||
return EnumToString<A2lTypedefType, 5>(type, kTypedefList); |
|||
} |
|||
|
|||
EnumStringList TypedefTypeToStringList() { |
|||
return EnumToStringList<A2lTypedefType,5>(kTypedefList); |
|||
} |
|||
|
|||
/*------------------- UNIT TYPE ----------------------*/ |
|||
using StringUnit = std::pair<std::string_view, A2lUnitType>; |
|||
constexpr std::array<StringUnit, 2> kUnitList = { |
|||
std::pair("DERIVED", A2lUnitType::DERIVED), |
|||
std::pair("EXTENDED_SI", A2lUnitType::EXTENDED_SI), |
|||
}; |
|||
|
|||
A2lUnitType StringToUnitType(const std::string& text) { |
|||
return StringToEnum<A2lUnitType, 2>(text, kUnitList); |
|||
} |
|||
|
|||
std::string_view UnitTypeToString(A2lUnitType type) { |
|||
return EnumToString<A2lUnitType, 2>(type, kUnitList); |
|||
} |
|||
|
|||
EnumStringList UnitTypeToStringList() { |
|||
return EnumToStringList<A2lUnitType,2>(kUnitList); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
/*
|
|||
* Copyright 2022 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/a2lfile.h" |
|||
#include <fstream> |
|||
#include <sstream> |
|||
#include <algorithm> |
|||
#include <filesystem> |
|||
#include <array> |
|||
#include <boost/locale.hpp> |
|||
#include <boost/endian.hpp> |
|||
#include "a2lscanner.h" |
|||
#include "a2lhelper.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
|
|||
std::string A2lFile::Name() const { |
|||
return A2lHelper::GetStem(filename_); |
|||
} |
|||
|
|||
bool A2lFile::ParseFile() { |
|||
last_error_.clear(); |
|||
bool parse = true; |
|||
try { |
|||
// Read in the file into a memory stream and convert to UTF8 coding at
|
|||
// the same time
|
|||
std::istringstream utf8_stream; |
|||
A2lScanner::ReadAndConvertFile(filename_, utf8_stream); |
|||
A2lScanner scanner(utf8_stream); |
|||
scanner.InputFile(filename_); // Needed in case of include files.
|
|||
scanner.Parent(this); |
|||
|
|||
// scanner.set_debug(2);
|
|||
A2lParser parser(scanner, *this); |
|||
parse = parser.parse() == 0; |
|||
IsA2lFile(scanner.IsA2lFile()); |
|||
last_error_ = scanner.LastError(); |
|||
|
|||
} catch (const std::exception& err) { |
|||
last_error_ = err.what(); |
|||
parse = false; |
|||
} catch (...) { |
|||
parse = false; |
|||
} |
|||
return parse; |
|||
} |
|||
|
|||
void A2lFile::Merge(A2lFile &include_file) { |
|||
// If this isn't an A2L file i.e. missing the project header, then copy the entire project.
|
|||
// Always move the modules
|
|||
auto& dest_project = Project(); |
|||
auto& remote_project = include_file.Project(); |
|||
if (!IsA2lFile()) { |
|||
dest_project.Header() = remote_project.Header(); |
|||
} |
|||
auto& dest_list = dest_project.Modules(); |
|||
auto& source_list = remote_project.Modules(); |
|||
for (auto& itr : source_list) { |
|||
dest_project.AddModule(itr.second); |
|||
} |
|||
source_list.clear(); |
|||
} |
|||
|
|||
} // namespace a2l
|
|||
File diff suppressed because it is too large
@ -0,0 +1,400 @@ |
|||
%top { |
|||
#include <cstdint> |
|||
#include <cctype> |
|||
|
|||
} |
|||
%{ |
|||
#include "a2lscanner.h" |
|||
#undef YY_DECL |
|||
#define YY_DECL int a2l::A2lScanner::a2llex(a2l::A2lParser::value_type* yy_value) |
|||
using token = a2l::A2lParser::token; |
|||
%} |
|||
|
|||
%option prefix="a2l" |
|||
%option 8bit |
|||
%option nounistd |
|||
%option noyywrap |
|||
%option debug |
|||
%option never-interactive |
|||
%option c++ |
|||
%option yyclass="a2l:A2lScanner" |
|||
%option yylineno |
|||
%option noinput |
|||
%option nounput |
|||
|
|||
|
|||
ws [ \t\n\v\f\r]+ |
|||
signed_number [-+]?[0-9]+ |
|||
unsigned_number [0-9]+ |
|||
hexnumber 0[xX][0-9a-fA-F]+ |
|||
float_val [-+]?[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)? |
|||
ident [a-zA-Z_]([\[\]()/_a-zA-Z0-9.-]*)? |
|||
string (\"(\\.|[^\\"])*\")* |
|||
/* \"([^\"\\]|(\\.))*\" */ |
|||
nl [\n\r] |
|||
keyword [A-Z_0-9]+ |
|||
|
|||
|
|||
%s PRI VERSION TIMESTAMP HOSTNAME APPNAME PROCID MSGID SD SDELEMENT SDPAR SDVALUE MSG |
|||
%% |
|||
%{ |
|||
yylval = yy_value; |
|||
%} |
|||
|
|||
|
|||
"ASAP2_VERSION" { return token::ASAP2_VERSION; } |
|||
"A2ML_VERSION" { return token::A2ML_VERSION; } |
|||
"ADDR_EPK" { return token::ADDR_EPK; } |
|||
"ADDRESS_TYPE" { return token::ADDRESS_TYPE; } |
|||
"ALIGNMENT_BYTE" { return token::ALIGNMENT_BYTE; } |
|||
"ALIGNMENT_FLOAT16_IEEE" { return token::ALIGNMENT_FLOAT16_IEEE; } |
|||
"ALIGNMENT_FLOAT32_IEEE" { return token::ALIGNMENT_FLOAT32_IEEE; } |
|||
"ALIGNMENT_FLOAT64_IEEE" { return token::ALIGNMENT_FLOAT64_IEEE; } |
|||
"ALIGNMENT_INT64" { return token::ALIGNMENT_INT64; } |
|||
"ALIGNMENT_LONG" { return token::ALIGNMENT_LONG; } |
|||
"ALIGNMENT_WORD" { return token::ALIGNMENT_WORD; } |
|||
"ANNOTATION" { return token::ANNOTATION; } |
|||
"ANNOTATION_LABEL" { return token::ANNOTATION_LABEL; } |
|||
"ANNOTATION_ORIGIN" { return token::ANNOTATION_ORIGIN; } |
|||
"ANNOTATION_TEXT" { return token::ANNOTATION_TEXT; } |
|||
"ARRAY_SIZE" { return token::ARRAY_SIZE; } |
|||
"AR_COMPONENT" { return token::AR_COMPONENT; } |
|||
"AR_PROTOTYPE_OF" { return token::AR_PROTOTYPE_OF; } |
|||
"AXIS_DESCR" { return token::AXIS_DESCR; } |
|||
"AXIS_PTS" { return token::AXIS_PTS; } |
|||
"AXIS_PTS_REF" { return token::AXIS_PTS_REF; } |
|||
"AXIS_PTS_X" { return token::AXIS_PTS_X; } |
|||
"AXIS_PTS_Y" { return token::AXIS_PTS_Y; } |
|||
"AXIS_PTS_Z" { return token::AXIS_PTS_Z; } |
|||
"AXIS_PTS_4" { return token::AXIS_PTS_4; } |
|||
"AXIS_PTS_5" { return token::AXIS_PTS_5; } |
|||
"AXIS_RESCALE_X" { return token::AXIS_RESCALE_X; } |
|||
"BIT_MASK" { return token::BIT_MASK; } |
|||
"BIT_OPERATION" { return token::BIT_OPERATION; } |
|||
"BLOB" { return token::BLOB; } |
|||
"BYTE_ORDER" { return token::A2L_BYTE_ORDER; } |
|||
"CALIBRATION_ACCESS" { return token::CALIBRATION_ACCESS; } |
|||
"CALIBRATION_HANDLE" { return token::CALIBRATION_HANDLE; } |
|||
"CALIBRATION_HANDLE_TEXT" { return token::CALIBRATION_HANDLE_TEXT; } |
|||
"CALIBRATION_METHOD" { return token::CALIBRATION_METHOD; } |
|||
"CHARACTERISTIC" { return token::CHARACTERISTIC; } |
|||
"COEFFS" { return token::COEFFS; } |
|||
"COEFFS_LINEAR" { return token::COEFFS_LINEAR; } |
|||
"COMPARISON_QUANTITY" { return token::COMPARISON_QUANTITY; } |
|||
"COMPU_METHOD" { return token::COMPU_METHOD; } |
|||
"COMPU_TAB" { return token::COMPU_TAB; } |
|||
"COMPU_TAB_REF" { return token::COMPU_TAB_REF; } |
|||
"COMPU_VTAB" { return token::COMPU_VTAB; } |
|||
"COMPU_VTAB_RANGE" { return token::COMPU_VTAB_RANGE; } |
|||
"CONSISTENT_EXCHANGE" { return token::CONSISTENT_EXCHANGE; } |
|||
"CONTROLLER_ADDRESSES" { return token::CONTROLLER_ADDRESSES; } |
|||
"CONVERSION" { return token::CONVERSION; } |
|||
"CPU_TYPE" { return token::CPU_TYPE; } |
|||
"CURVE_AXIS_REF" { return token::CURVE_AXIS_REF; } |
|||
"CUSTOMER" { return token::CUSTOMER; } |
|||
"CUSTOMER_NO" { return token::CUSTOMER_NO; } |
|||
"DATA_SIZE" { return token::DATA_SIZE; } |
|||
"DEF_CHARACTERISTIC" { return token::DEF_CHARACTERISTIC; } |
|||
"DEFAULT_VALUE" { return token::DEFAULT_VALUE; } |
|||
"DEFAULT_VALUE_NUMERIC" { return token::DEFAULT_VALUE_NUMERIC; } |
|||
"DEPENDENT_CHARACTERISTIC" { return token::DEPENDENT_CHARACTERISTIC; } |
|||
"DEPOSIT" { return token::DEPOSIT; } |
|||
"DISCRETE" { return token::DISCRETE; } |
|||
"DISPLAY_IDENTIFIER" { return token::DISPLAY_IDENTIFIER; } |
|||
"DIST_OP_X" { return token::DIST_OP_X; } |
|||
"DIST_OP_Y" { return token::DIST_OP_Y; } |
|||
"DIST_OP_Z" { return token::DIST_OP_Z; } |
|||
"DIST_OP_4" { return token::DIST_OP_4; } |
|||
"DIST_OP_5" { return token::DIST_OP_5; } |
|||
"ECU" { return token::ECU; } |
|||
"ECU_ADDRESS" { return token::ECU_ADDRESS; } |
|||
"ECU_ADDRESS_EXTENSION" { return token::ECU_ADDRESS_EXTENSION; } |
|||
"ECU_CALIBRATION_OFFSET" { return token::ECU_CALIBRATION_OFFSET; } |
|||
"ENCODING" { return token::ENCODING; } |
|||
"EPK" { return token::EPK; } |
|||
"ERROR_MASK" { return token::ERROR_MASK; } |
|||
"EXTENDED_LIMITS" { return token::EXTENDED_LIMITS; } |
|||
"FIX_AXIS_PAR" { return token::FIX_AXIS_PAR; } |
|||
"FIX_AXIS_PAR_DIST" { return token::FIX_AXIS_PAR_DIST; } |
|||
"FIX_AXIS_PAR_LIST" { return token::FIX_AXIS_PAR_LIST; } |
|||
"FIX_NO_AXIS_PTS_X" { return token::FIX_NO_AXIS_PTS_X; } |
|||
"FIX_NO_AXIS_PTS_Y" { return token::FIX_NO_AXIS_PTS_Y; } |
|||
"FIX_NO_AXIS_PTS_Z" { return token::FIX_NO_AXIS_PTS_Z; } |
|||
"FIX_NO_AXIS_PTS_4" { return token::FIX_NO_AXIS_PTS_4; } |
|||
"FIX_NO_AXIS_PTS_5" { return token::FIX_NO_AXIS_PTS_5; } |
|||
"FNC_VALUES" { return token::FNC_VALUES; } |
|||
"FORMAT" { return token::FORMAT; } |
|||
"FORMULA" { return token::FORMULA; } |
|||
"FORMULA_INV" { return token::FORMULA_INV; } |
|||
"FRAME" { return token::FRAME; } |
|||
"FRAME_MEASUREMENT" { return token::FRAME_MEASUREMENT; } |
|||
"FUNCTION" { return token::FUNCTION; } |
|||
"FUNCTION_LIST" { return token::FUNCTION_LIST; } |
|||
"FUNCTION_VERSION" { return token::FUNCTION_VERSION; } |
|||
"GROUP" { return token::GROUP; } |
|||
"GUARD_RAILS" { return token::GUARD_RAILS; } |
|||
"HEADER" { return token::HEADER; } |
|||
"IDENTIFICATION" { return token::IDENTIFICATION; } |
|||
"IN_MEASUREMENT" { return token::IN_MEASUREMENT; } |
|||
"INPUT_QUANTITY" { return token::INPUT_QUANTITY; } |
|||
"INSTANCE" { return token::INSTANCE; } |
|||
"LAYOUT" { return token::LAYOUT; } |
|||
"LEFT_SHIFT" { return token::LEFT_SHIFT; } |
|||
"LIMITS" { return token::LIMITS; } |
|||
"LOC_MEASUREMENT" { return token::LOC_MEASUREMENT; } |
|||
"MAP_LIST" { return token::MAP_LIST; } |
|||
"MATRIX_DIM" { return token::MATRIX_DIM; } |
|||
"MAX_GRAD" { return token::MAX_GRAD; } |
|||
"MAX_REFRESH" { return token::MAX_REFRESH; } |
|||
"MEASUREMENT" { return token::MEASUREMENT; } |
|||
"MEMORY_LAYOUT" { return token::MEMORY_LAYOUT; } |
|||
"MEMORY_SEGMENT" { return token::MEMORY_SEGMENT; } |
|||
"MOD_COMMON" { return token::MOD_COMMON; } |
|||
"MOD_PAR" { return token::MOD_PAR; } |
|||
"MODEL_LINK" { return token::MODEL_LINK; } |
|||
"MODULE" { return token::MODULE; } |
|||
"MONOTONY" { return token::MONOTONY; } |
|||
"NO_AXIS_PTS_X" { return token::NO_AXIS_PTS_X; } |
|||
"NO_AXIS_PTS_Y" { return token::NO_AXIS_PTS_Y; } |
|||
"NO_AXIS_PTS_Z" { return token::NO_AXIS_PTS_Z; } |
|||
"NO_AXIS_PTS_4" { return token::NO_AXIS_PTS_4; } |
|||
"NO_AXIS_PTS_5" { return token::NO_AXIS_PTS_5; } |
|||
"NO_OF_INTERFACES" { return token::NO_OF_INTERFACES; } |
|||
"NO_RESCALE_X" { return token::NO_RESCALE_X; } |
|||
"NUMBER" { return token::NUMBER; } |
|||
"OFFSET_X" { return token::OFFSET_X; } |
|||
"OFFSET_Y" { return token::OFFSET_Y; } |
|||
"OFFSET_Z" { return token::OFFSET_Z; } |
|||
"OFFSET_4" { return token::OFFSET_4; } |
|||
"OFFSET_5" { return token::OFFSET_5; } |
|||
"OUT_MEASUREMENT" { return token::OUT_MEASUREMENT; } |
|||
"OVERWRITE" { return token::OVERWRITE; } |
|||
"PHONE_NO" { return token::PHONE_NO; } |
|||
"PHYS_UNIT" { return token::PHYS_UNIT; } |
|||
"PROJECT" { |
|||
found_ = true; |
|||
return token::PROJECT; |
|||
} |
|||
"PROJECT_NO" { return token::PROJECT_NO; } |
|||
"READ_ONLY" { return token::READ_ONLY; } |
|||
"READ_WRITE" { return token::READ_WRITE; } |
|||
"RECORD_LAYOUT" { return token::RECORD_LAYOUT; } |
|||
"REF_CHARACTERISTIC" { return token::REF_CHARACTERISTIC; } |
|||
"REF_GROUP" { return token::REF_GROUP; } |
|||
"REF_MEASUREMENT" { return token::REF_MEASUREMENT; } |
|||
"REF_MEMORY_SEGMENT" { return token::REF_MEMORY_SEGMENT; } |
|||
"REF_UNIT" { return token::REF_UNIT; } |
|||
"RESERVED" { return token::RESERVED; } |
|||
"RIGHT_SHIFT" { return token::RIGHT_SHIFT; } |
|||
"RIP_ADDR_W" { return token::RIP_ADDR_W; } |
|||
"RIP_ADDR_X" { return token::RIP_ADDR_X; } |
|||
"RIP_ADDR_Y" { return token::RIP_ADDR_Y; } |
|||
"RIP_ADDR_Z" { return token::RIP_ADDR_Z; } |
|||
"RIP_ADDR_4" { return token::RIP_ADDR_4; } |
|||
"RIP_ADDR_5" { return token::RIP_ADDR_5; } |
|||
"ROOT" { return token::ROOT; } |
|||
"S_REC_LAYOUT" { return token::S_REC_LAYOUT; } /* Deprecated */ |
|||
"SHIFT_OP_X" { return token::SHIFT_OP_X; } |
|||
"SHIFT_OP_Y" { return token::SHIFT_OP_Y; } |
|||
"SHIFT_OP_Z" { return token::SHIFT_OP_Z; } |
|||
"SHIFT_OP_4" { return token::SHIFT_OP_4; } |
|||
"SHIFT_OP_5" { return token::SHIFT_OP_5; } |
|||
"SIGN_EXTEND" { return token::SIGN_EXTEND; } |
|||
"SI_EXPONENTS" { return token::SI_EXPONENTS; } |
|||
"SRC_ADDR_X" { return token::SRC_ADDR_X; } |
|||
"SRC_ADDR_Y" { return token::SRC_ADDR_Y; } |
|||
"SRC_ADDR_Z" { return token::SRC_ADDR_Z; } |
|||
"SRC_ADDR_4" { return token::SRC_ADDR_4; } |
|||
"SRC_ADDR_5" { return token::SRC_ADDR_5; } |
|||
"STATIC_ADDRESS_OFFSETS" { return token::STATIC_ADDRESS_OFFSETS; } |
|||
"STATIC_RECORD_LAYOUT" { return token::STATIC_RECORD_LAYOUT; } |
|||
"STATUS_STRING_REF" { return token::STATUS_STRING_REF; } |
|||
"STEP_SIZE" { return token::STEP_SIZE; } |
|||
"STRUCTURE_COMPONENT" { return token::STRUCTURE_COMPONENT; } |
|||
"SUB_FUNCTION" { return token::SUB_FUNCTION; } |
|||
"SUB_GROUP" { return token::SUB_GROUP; } |
|||
"SUPPLIER" { return token::SUPPLIER; } |
|||
"SYMBOL_LINK" { return token::SYMBOL_LINK; } |
|||
"SYMBOL_TYPE_LINK" { return token::SYMBOL_TYPE_LINK; } |
|||
"SYSTEM_CONSTANT" { return token::SYSTEM_CONSTANT; } |
|||
"TRANSFORMER" { return token::TRANSFORMER; } |
|||
"TRANSFORMER_IN_OBJECTS" { return token::TRANSFORMER_IN_OBJECTS; } |
|||
"TRANSFORMER_OUT_OBJECTS" { return token::TRANSFORMER_OUT_OBJECTS; } |
|||
"TYPEDEF_AXIS" { return token::TYPEDEF_AXIS; } |
|||
"TYPEDEF_BLOB" { return token::TYPEDEF_BLOB; } |
|||
"TYPEDEF_CHARACTERISTIC" { return token::TYPEDEF_CHARACTERISTIC; } |
|||
"TYPEDEF_MEASUREMENT" { return token::TYPEDEF_MEASUREMENT; } |
|||
"TYPEDEF_STRUCTURE" { return token::TYPEDEF_STRUCTURE; } |
|||
"UNIT" { return token::UNIT; } |
|||
"UNIT_CONVERSION" { return token::UNIT_CONVERSION; } |
|||
"USER" { return token::USER; } |
|||
"USER_RIGHTS" { return token::USER_RIGHTS; } |
|||
"VAR_ADDRESS" { return token::VAR_ADDRESS; } |
|||
"VAR_CHARACTERISTIC" { return token::VAR_CHARACTERISTIC; } |
|||
"VAR_CRITERION" { return token::VAR_CRITERION; } |
|||
"VAR_FORBIDDEN_COMB" { return token::VAR_FORBIDDEN_COMB; } |
|||
"VAR_MEASUREMENT" { return token::VAR_MEASUREMENT; } |
|||
"VAR_NAMING" { return token::VAR_NAMING; } |
|||
"VAR_SELECTION_CHARACTERISTIC" { return token::VAR_SELECTION_CHARACTERISTIC; } |
|||
"VAR_SEPARATOR" { return token::VAR_SEPARATOR; } |
|||
"VARIANT_CODING" { return token::VARIANT_CODING; } |
|||
"VERSION" { return token::A2L_VERSION; } |
|||
"VIRTUAL" { return token::VIRTUAL; } |
|||
"VIRTUAL_CHARACTERISTIC" { return token::VIRTUAL_CHARACTERISTIC; } |
|||
|
|||
"/begin"{ws}"A2ML" { |
|||
// Read in the format specification |
|||
if (yylval != nullptr) { |
|||
yylval->emplace<std::string>(ReadA2ML()); |
|||
} |
|||
return token::A2ML; |
|||
} |
|||
|
|||
"/begin"{ws}"IF_DATA" { |
|||
// Read in the if_data string |
|||
if (yylval != nullptr) { |
|||
yylval->emplace<std::string>(ReadIfData()); |
|||
} |
|||
return token::IF_DATA; |
|||
} |
|||
"IF_DATA"{ws}"{" { |
|||
// Read in the if_data string until end of line |
|||
if(yylval != nullptr ) { |
|||
yylval->emplace<std::string>(ReadIfDataMultiLine()); |
|||
} |
|||
return token::IF_DATA; |
|||
} |
|||
"IF_DATA" { |
|||
// Read in the if_data string until end of line |
|||
if (yylval != nullptr) { |
|||
yylval->emplace<std::string>(ReadIfDataSingleLine()); |
|||
} |
|||
return token::IF_DATA; |
|||
} |
|||
"FUNCTION"{ws}"{" { SkipUntil('}'); } |
|||
|
|||
"/begin" { return token::A2L_BEGIN; } |
|||
"/end" { return token::A2L_END; } |
|||
|
|||
"/include" { |
|||
FixIncludeFile(); |
|||
} |
|||
|
|||
|
|||
|
|||
{ident} { |
|||
const std::string temp(yytext); |
|||
if (yylval != nullptr) { |
|||
yylval->emplace<std::string>(temp); |
|||
} |
|||
return token::IDENT; |
|||
} |
|||
|
|||
{string} { |
|||
const size_t len = strlen(yytext); |
|||
std::string temp; |
|||
if (len > 2) { |
|||
temp = yytext + 1; |
|||
temp.pop_back(); |
|||
} |
|||
yylval->emplace<std::string>(temp); |
|||
return token::STRING; |
|||
} |
|||
|
|||
{hexnumber} { |
|||
uint64_t address = 0; |
|||
for ( size_t index = 0; yytext[ index ] != '\0'; ++index ) { |
|||
if ( index < 2 ) continue; |
|||
const char token = yytext[index]; |
|||
switch ( token ) { |
|||
case '0': |
|||
case '1': |
|||
case '2': |
|||
case '3': |
|||
case '4': |
|||
case '5': |
|||
case '6': |
|||
case '7': |
|||
case '8': |
|||
case '9': |
|||
address *= 16; |
|||
address += token - '0'; |
|||
break; |
|||
|
|||
case 'A': |
|||
case 'B': |
|||
case 'C': |
|||
case 'D': |
|||
case 'E': |
|||
case 'F': |
|||
address *= 16; |
|||
address += token - 'A' + 10; |
|||
break; |
|||
|
|||
case 'a': |
|||
case 'b': |
|||
case 'c': |
|||
case 'd': |
|||
case 'e': |
|||
case 'f': |
|||
address *= 16; |
|||
address += token - 'a' + 10; |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
yylval->emplace<uint64_t>(address); |
|||
return token::HEX; |
|||
} |
|||
{unsigned_number} { |
|||
uint64_t temp = 0; |
|||
try { |
|||
temp = std::stoull(yytext); |
|||
} catch (const std::exception& ) { |
|||
|
|||
} |
|||
yylval->emplace<uint64_t>(temp); |
|||
return token::UINT; |
|||
} |
|||
{signed_number} { |
|||
int64_t temp = 0; |
|||
try { |
|||
temp = std::stoll(yytext); |
|||
} catch (const std::exception& ) { |
|||
|
|||
} |
|||
yylval->emplace<int64_t>(temp); |
|||
return token::INT; |
|||
} |
|||
{float_val} { |
|||
double temp = 0.0; |
|||
try { |
|||
temp = std::stod(yytext); |
|||
} catch (const std::exception&) { |
|||
|
|||
} |
|||
yylval->emplace<double>(temp); |
|||
return token::FLOAT; |
|||
} |
|||
|
|||
[/][*][^*]*[*]+([^*/][^*]*[*]+)*[/] { } /* Multi line comments */ |
|||
"//".* { /* Single line comment */ } |
|||
{ws} {} |
|||
. {} |
|||
<<EOF>> { |
|||
if (file_stack_.size() <= 1) { |
|||
yyterminate(); |
|||
} else { |
|||
auto& last_item = file_stack_.back(); |
|||
yy_delete_buffer(last_item.buffer_state); |
|||
file_stack_.pop_back(); |
|||
auto& current_item = file_stack_.back(); |
|||
yy_switch_to_buffer(current_item.buffer_state); |
|||
} |
|||
} |
|||
%% |
|||
|
|||
|
|||
@ -0,0 +1,706 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2lhelper.h" |
|||
#include <cstring> |
|||
#include <fstream> |
|||
#include <sstream> |
|||
|
|||
namespace { |
|||
constexpr uint8_t kMask[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; |
|||
using signed64 = union { |
|||
int64_t val1 : 1; |
|||
int64_t val2 : 2; |
|||
int64_t val3 : 3; |
|||
int64_t val4 : 4; |
|||
int64_t val5 : 5; |
|||
int64_t val6 : 6; |
|||
int64_t val7 : 7; |
|||
int64_t val8 : 8; |
|||
int64_t val9 : 9; |
|||
int64_t val10 : 10; |
|||
int64_t val11 : 11; |
|||
int64_t val12 : 12; |
|||
int64_t val13 : 13; |
|||
int64_t val14 : 14; |
|||
int64_t val15 : 15; |
|||
int64_t val16 : 16; |
|||
int64_t val17 : 17; |
|||
int64_t val18 : 18; |
|||
int64_t val19 : 19; |
|||
int64_t val20 : 20; |
|||
int64_t val21 : 21; |
|||
int64_t val22 : 22; |
|||
int64_t val23 : 23; |
|||
int64_t val24 : 24; |
|||
int64_t val25 : 25; |
|||
int64_t val26 : 26; |
|||
int64_t val27 : 27; |
|||
int64_t val28 : 28; |
|||
int64_t val29 : 29; |
|||
int64_t val30 : 30; |
|||
int64_t val31 : 31; |
|||
int64_t val32 : 32; |
|||
int64_t val33 : 33; |
|||
int64_t val34 : 34; |
|||
int64_t val35 : 35; |
|||
int64_t val36 : 36; |
|||
int64_t val37 : 37; |
|||
int64_t val38 : 38; |
|||
int64_t val39 : 39; |
|||
int64_t val40 : 40; |
|||
int64_t val41 : 41; |
|||
int64_t val42 : 42; |
|||
int64_t val43 : 43; |
|||
int64_t val44 : 44; |
|||
int64_t val45 : 45; |
|||
int64_t val46 : 46; |
|||
int64_t val47 : 47; |
|||
int64_t val48 : 48; |
|||
int64_t val49 : 49; |
|||
int64_t val50 : 50; |
|||
int64_t val51 : 51; |
|||
int64_t val52 : 52; |
|||
int64_t val53 : 53; |
|||
int64_t val54 : 54; |
|||
int64_t val55 : 55; |
|||
int64_t val56 : 56; |
|||
int64_t val57 : 57; |
|||
int64_t val58 : 58; |
|||
int64_t val59 : 59; |
|||
int64_t val60 : 60; |
|||
int64_t val61 : 61; |
|||
int64_t val62 : 62; |
|||
int64_t val63 : 63; |
|||
int64_t val64 : 64; |
|||
}; |
|||
|
|||
} // end namespace empty
|
|||
|
|||
namespace a2l { |
|||
|
|||
void A2lHelper::DoubleToRaw(bool little_endian, size_t start, size_t length, |
|||
double value, uint8_t* dest) { |
|||
if (dest == nullptr || length < 64) { |
|||
return; |
|||
} |
|||
length = 64; |
|||
|
|||
uint64_t mask = 1ULL << 63; |
|||
uint64_t temp = 0; |
|||
memcpy(&temp, &value, sizeof(temp)); |
|||
|
|||
auto bit = little_endian ? static_cast<int>(start + length - 1) |
|||
: static_cast<int>(start); |
|||
|
|||
auto byte = bit / 8; |
|||
bit %= 8; |
|||
|
|||
for (size_t index = 0; index < length; ++index) { |
|||
if ((temp & mask) != 0) { |
|||
dest[byte] |= kMask[bit]; |
|||
} else { |
|||
dest[byte] &= ~kMask[bit]; |
|||
} |
|||
mask >>= 1; |
|||
--bit; |
|||
if (bit < 0) { |
|||
bit = 7; |
|||
little_endian ? --byte : ++byte; |
|||
} |
|||
if (byte >= (start + length) /8) { |
|||
// Buffer overrun. Most likely invalid start bit
|
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
void A2lHelper::FloatToRaw(bool little_endian, size_t start, size_t length, |
|||
float value, uint8_t* raw) { |
|||
if (raw == nullptr || length < 32) { |
|||
return; |
|||
} |
|||
length = 32; |
|||
uint32_t mask = 1UL << 31; |
|||
uint32_t temp = 0; |
|||
memcpy(&temp, &value, sizeof(temp)); |
|||
|
|||
auto bit = little_endian ? static_cast<int>(start + length - 1) |
|||
: static_cast<int>(start); |
|||
|
|||
auto byte = bit / 8; |
|||
bit %= 8; |
|||
for (size_t index = 0; index < length; ++index) { |
|||
if ((temp & mask) != 0) { |
|||
raw[byte] |= kMask[bit]; |
|||
} else { |
|||
raw[byte] &= ~kMask[bit]; |
|||
} |
|||
mask >>= 1; |
|||
--bit; |
|||
if (bit < 0) { |
|||
bit = 7; |
|||
little_endian ? --byte : ++byte; |
|||
} |
|||
if (byte >= (start + length) / 8) { |
|||
// Buffer overrun. Most likely invalid start bit
|
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
void A2lHelper::SignedToRaw(bool little_endian, size_t start, size_t length, |
|||
int64_t value, uint8_t* raw) { |
|||
if (raw == nullptr || length == 0) { |
|||
return; |
|||
} |
|||
|
|||
signed64 temp_val{}; |
|||
|
|||
switch (length) { |
|||
case 1: |
|||
temp_val.val1 = value; |
|||
break; |
|||
case 2: |
|||
temp_val.val2 = value; |
|||
break; |
|||
case 3: |
|||
temp_val.val3 = value; |
|||
break; |
|||
case 4: |
|||
temp_val.val4 = value; |
|||
break; |
|||
case 5: |
|||
temp_val.val5 = value; |
|||
break; |
|||
case 6: |
|||
temp_val.val6 = value; |
|||
break; |
|||
case 7: |
|||
temp_val.val7 = value; |
|||
break; |
|||
case 8: |
|||
temp_val.val8 = value; |
|||
break; |
|||
case 9: |
|||
temp_val.val9 = value; |
|||
break; |
|||
case 10: |
|||
temp_val.val10 = value; |
|||
break; |
|||
case 11: |
|||
temp_val.val11 = value; |
|||
break; |
|||
case 12: |
|||
temp_val.val12 = value; |
|||
break; |
|||
case 13: |
|||
temp_val.val13 = value; |
|||
break; |
|||
case 14: |
|||
temp_val.val14 = value; |
|||
break; |
|||
case 15: |
|||
temp_val.val15 = value; |
|||
break; |
|||
case 16: |
|||
temp_val.val16 = value; |
|||
break; |
|||
case 17: |
|||
temp_val.val17 = value; |
|||
break; |
|||
case 18: |
|||
temp_val.val18 = value; |
|||
break; |
|||
case 19: |
|||
temp_val.val19 = value; |
|||
break; |
|||
case 20: |
|||
temp_val.val20 = value; |
|||
break; |
|||
case 21: |
|||
temp_val.val21 = value; |
|||
break; |
|||
case 22: |
|||
temp_val.val22 = value; |
|||
break; |
|||
case 23: |
|||
temp_val.val23 = value; |
|||
break; |
|||
case 24: |
|||
temp_val.val24 = value; |
|||
break; |
|||
case 25: |
|||
temp_val.val25 = value; |
|||
break; |
|||
case 26: |
|||
temp_val.val26 = value; |
|||
break; |
|||
case 27: |
|||
temp_val.val27 = value; |
|||
break; |
|||
case 28: |
|||
temp_val.val28 = value; |
|||
break; |
|||
case 29: |
|||
temp_val.val29 = value; |
|||
break; |
|||
case 30: |
|||
temp_val.val30 = value; |
|||
break; |
|||
case 31: |
|||
temp_val.val31 = value; |
|||
break; |
|||
case 32: |
|||
temp_val.val32 = value; |
|||
break; |
|||
case 33: |
|||
temp_val.val33 = value; |
|||
break; |
|||
case 34: |
|||
temp_val.val34 = value; |
|||
break; |
|||
case 35: |
|||
temp_val.val35 = value; |
|||
break; |
|||
case 36: |
|||
temp_val.val36 = value; |
|||
break; |
|||
case 37: |
|||
temp_val.val37 = value; |
|||
break; |
|||
case 38: |
|||
temp_val.val38 = value; |
|||
break; |
|||
case 39: |
|||
temp_val.val39 = value; |
|||
break; |
|||
case 40: |
|||
temp_val.val40 = value; |
|||
break; |
|||
case 41: |
|||
temp_val.val41 = value; |
|||
break; |
|||
case 42: |
|||
temp_val.val42 = value; |
|||
break; |
|||
case 43: |
|||
temp_val.val43 = value; |
|||
break; |
|||
case 44: |
|||
temp_val.val44 = value; |
|||
break; |
|||
case 45: |
|||
temp_val.val45 = value; |
|||
break; |
|||
case 46: |
|||
temp_val.val46 = value; |
|||
break; |
|||
case 47: |
|||
temp_val.val47 = value; |
|||
break; |
|||
case 48: |
|||
temp_val.val48 = value; |
|||
break; |
|||
case 49: |
|||
temp_val.val49 = value; |
|||
break; |
|||
case 50: |
|||
temp_val.val50 = value; |
|||
break; |
|||
case 51: |
|||
temp_val.val51 = value; |
|||
break; |
|||
case 52: |
|||
temp_val.val52 = value; |
|||
break; |
|||
case 53: |
|||
temp_val.val53 = value; |
|||
break; |
|||
case 54: |
|||
temp_val.val54 = value; |
|||
break; |
|||
case 55: |
|||
temp_val.val55 = value; |
|||
break; |
|||
case 56: |
|||
temp_val.val56 = value; |
|||
break; |
|||
case 57: |
|||
temp_val.val57 = value; |
|||
break; |
|||
case 58: |
|||
temp_val.val58 = value; |
|||
break; |
|||
case 59: |
|||
temp_val.val59 = value; |
|||
break; |
|||
case 60: |
|||
temp_val.val60 = value; |
|||
break; |
|||
case 61: |
|||
temp_val.val61 = value; |
|||
break; |
|||
case 62: |
|||
temp_val.val62 = value; |
|||
break; |
|||
case 63: |
|||
temp_val.val63 = value; |
|||
break; |
|||
case 64: |
|||
temp_val.val64 = value; |
|||
break; |
|||
default: |
|||
return; |
|||
} |
|||
|
|||
uint64_t mask = 1ULL << (length - 1); |
|||
uint64_t temp = 0; |
|||
memcpy(&temp, &temp_val, sizeof(temp)); |
|||
auto bit = little_endian ? static_cast<int>(start + length - 1) |
|||
: static_cast<int>(start); |
|||
auto byte = bit / 8; |
|||
bit %= 8; |
|||
for (size_t index = 0; index < length; ++index) { |
|||
if ((temp & mask) != 0) { |
|||
raw[byte] |= kMask[bit]; |
|||
} else { |
|||
raw[byte] &= ~kMask[bit]; |
|||
} |
|||
mask >>= 1; |
|||
--bit; |
|||
if (bit < 0) { |
|||
bit = 7; |
|||
little_endian ? --byte : ++byte; |
|||
} |
|||
} |
|||
} |
|||
|
|||
void A2lHelper::UnsignedToRaw(bool little_endian, size_t start, size_t length, |
|||
uint64_t value, uint8_t* raw) { |
|||
if (raw == nullptr || length == 0) { |
|||
return; |
|||
} |
|||
|
|||
uint64_t mask = 1ULL << (length - 1); |
|||
auto bit = little_endian ? static_cast<int>(start + length - 1) |
|||
: static_cast<int>(start); |
|||
auto byte = bit / 8; |
|||
bit %= 8; |
|||
|
|||
for (size_t index = 0; index < length; ++index) { |
|||
if ((value & mask) != 0) { |
|||
raw[byte] |= kMask[bit]; |
|||
} else { |
|||
raw[byte] &= ~kMask[bit]; |
|||
} |
|||
mask >>= 1; |
|||
--bit; |
|||
if (bit < 0) { |
|||
bit = 7; |
|||
little_endian ? --byte : ++byte; |
|||
} |
|||
} |
|||
} |
|||
|
|||
std::vector<uint8_t> A2lHelper::RawToByteArray(size_t start, size_t length, |
|||
const unsigned char* raw ) |
|||
{ |
|||
// Only byte aligned strings are supported
|
|||
if ( raw == nullptr || (length % 8) != 0 || (start % 8) != 0) { |
|||
return {}; |
|||
} |
|||
const auto byte_start = start / 8; |
|||
const auto byte_size = length / 8; |
|||
std::vector<uint8_t> temp; |
|||
temp.resize(byte_size, 0); |
|||
memcpy(temp.data(), raw + byte_start, byte_size); |
|||
return temp; |
|||
} |
|||
|
|||
double A2lHelper::RawToDouble(bool little_endian, size_t start, size_t length, |
|||
const unsigned char* raw ) |
|||
{ |
|||
double value = 0.0; |
|||
uint64_t temp = 0; |
|||
uint64_t mask = 1ULL << ( length - 1 ); |
|||
auto bit = little_endian ? static_cast<int>(start + length - 1) |
|||
: static_cast<int>(start); |
|||
auto byte = bit / 8; |
|||
bit %= 8; |
|||
for (size_t index = 0; index < length; ++index ) { |
|||
if ((raw[byte] & kMask[bit] ) != 0) { |
|||
temp |= mask; |
|||
} |
|||
mask >>= 1; |
|||
--bit; |
|||
if (bit < 0) { |
|||
bit = 7; |
|||
little_endian ? --byte : ++byte; |
|||
} |
|||
} |
|||
memcpy( &value, &temp, sizeof(value)); |
|||
return value; |
|||
} |
|||
|
|||
float A2lHelper::RawToFloat(bool little_endian, size_t start, size_t length, |
|||
const unsigned char* raw ) |
|||
{ |
|||
float value = 0.0; |
|||
uint32_t temp = 0; |
|||
uint32_t mask = 1ULL << ( length - 1 ); |
|||
auto bit = little_endian ? static_cast<int>(start + length - 1) |
|||
: static_cast<int>(start); |
|||
auto byte = bit / 8; |
|||
bit %= 8; |
|||
for (size_t index = 0; index < length; ++index ) { |
|||
if ((raw[byte] & kMask[bit] ) != 0) { |
|||
temp |= mask; |
|||
} |
|||
mask >>= 1; |
|||
--bit; |
|||
if (bit < 0) { |
|||
bit = 7; |
|||
little_endian ? --byte : ++byte; |
|||
} |
|||
} |
|||
memcpy( &value, &temp, sizeof(value)); |
|||
return value; |
|||
} |
|||
|
|||
int64_t A2lHelper::RawToSigned(bool little_endian, size_t start, size_t length, |
|||
const uint8_t* raw ) |
|||
{ |
|||
int64_t value = 0; |
|||
|
|||
uint64_t temp = 0; |
|||
auto bit = little_endian ? static_cast<int>(start + length - 1) |
|||
: static_cast<int>(start); |
|||
auto byte = bit / 8; |
|||
bit %= 8; |
|||
|
|||
for (size_t index = 0; index < length; ++index) { |
|||
if ( index > 0 ) temp <<= 1; |
|||
if ((raw[byte] & kMask[bit]) != 0) { |
|||
temp |= 1; |
|||
} |
|||
--bit; |
|||
if (bit < 0) { |
|||
bit = 7; |
|||
little_endian ? --byte : ++byte; |
|||
} |
|||
} |
|||
|
|||
signed64 temp_value {}; |
|||
memcpy( &temp_value, &temp, sizeof(temp)); |
|||
|
|||
switch ( length ) { |
|||
case 1: value = temp_value.val1; break; |
|||
case 2: value = temp_value.val2; break; |
|||
case 3: value = temp_value.val3; break; |
|||
case 4: value = temp_value.val4; break; |
|||
case 5: value = temp_value.val5; break; |
|||
case 6: value = temp_value.val6; break; |
|||
case 7: value = temp_value.val7; break; |
|||
case 8: value = temp_value.val8; break; |
|||
case 9: value = temp_value.val9; break; |
|||
case 10: value = temp_value.val10; break; |
|||
case 11: value = temp_value.val11; break; |
|||
case 12: value = temp_value.val12; break; |
|||
case 13: value = temp_value.val13; break; |
|||
case 14: value = temp_value.val14; break; |
|||
case 15: value = temp_value.val15; break; |
|||
case 16: value = temp_value.val16; break; |
|||
case 17: value = temp_value.val17; break; |
|||
case 18: value = temp_value.val18; break; |
|||
case 19: value = temp_value.val19; break; |
|||
case 20: value = temp_value.val20; break; |
|||
case 21: value = temp_value.val21; break; |
|||
case 22: value = temp_value.val22; break; |
|||
case 23: value = temp_value.val23; break; |
|||
case 24: value = temp_value.val24; break; |
|||
case 25: value = temp_value.val25; break; |
|||
case 26: value = temp_value.val26; break; |
|||
case 27: value = temp_value.val27; break; |
|||
case 28: value = temp_value.val28; break; |
|||
case 29: value = temp_value.val29; break; |
|||
case 30: value = temp_value.val30; break; |
|||
case 31: value = temp_value.val31; break; |
|||
case 32: value = temp_value.val32; break; |
|||
case 33: value = temp_value.val33; break; |
|||
case 34: value = temp_value.val34; break; |
|||
case 35: value = temp_value.val35; break; |
|||
case 36: value = temp_value.val36; break; |
|||
case 37: value = temp_value.val37; break; |
|||
case 38: value = temp_value.val38; break; |
|||
case 39: value = temp_value.val39; break; |
|||
case 40: value = temp_value.val40; break; |
|||
case 41: value = temp_value.val41; break; |
|||
case 42: value = temp_value.val42; break; |
|||
case 43: value = temp_value.val43; break; |
|||
case 44: value = temp_value.val44; break; |
|||
case 45: value = temp_value.val45; break; |
|||
case 46: value = temp_value.val46; break; |
|||
case 47: value = temp_value.val47; break; |
|||
case 48: value = temp_value.val48; break; |
|||
case 49: value = temp_value.val49; break; |
|||
case 50: value = temp_value.val50; break; |
|||
case 51: value = temp_value.val51; break; |
|||
case 52: value = temp_value.val52; break; |
|||
case 53: value = temp_value.val53; break; |
|||
case 54: value = temp_value.val54; break; |
|||
case 55: value = temp_value.val55; break; |
|||
case 56: value = temp_value.val56; break; |
|||
case 57: value = temp_value.val57; break; |
|||
case 58: value = temp_value.val58; break; |
|||
case 59: value = temp_value.val59; break; |
|||
case 60: value = temp_value.val60; break; |
|||
case 61: value = temp_value.val61; break; |
|||
case 62: value = temp_value.val62; break; |
|||
case 63: value = temp_value.val63; break; |
|||
case 64: value = temp_value.val64; break; |
|||
default: |
|||
break; |
|||
} |
|||
return value; |
|||
} |
|||
|
|||
uint64_t A2lHelper::RawToUnsigned(bool little_endian, size_t start, |
|||
size_t length, const uint8_t* raw) |
|||
{ |
|||
uint64_t value = 0; |
|||
|
|||
auto bit = little_endian ? static_cast<int>(start + length - 1) |
|||
: static_cast<int>(start); |
|||
auto byte = bit / 8; |
|||
bit %= 8; |
|||
|
|||
for (size_t index = 0; index < length; ++index) { |
|||
if (index > 0) { |
|||
value <<= 1; |
|||
} |
|||
if ((raw[byte] & kMask[bit]) != 0) { |
|||
value |= 1; |
|||
} |
|||
--bit; |
|||
if (bit < 0) { |
|||
bit = 7; |
|||
little_endian ? --byte : ++byte; |
|||
} |
|||
} |
|||
return value; |
|||
} |
|||
|
|||
void A2lHelper::SetAllBits(size_t start, size_t length, uint8_t* raw ) { |
|||
if (raw == nullptr) { |
|||
return; |
|||
} |
|||
|
|||
for ( size_t index = 0; index < length; ++index) { |
|||
auto bit = start + index; |
|||
const auto byte = bit / 8; |
|||
bit %= 8; |
|||
raw[byte] |= kMask[bit]; |
|||
} |
|||
} |
|||
|
|||
bool A2lHelper::IsAllBitsSet(size_t start, size_t length, const uint8_t* raw) { |
|||
if (raw == nullptr) { |
|||
return true; |
|||
} |
|||
if (length <= 1) { |
|||
return false; // 1 bit cannot have an invalid flag
|
|||
} |
|||
for (size_t index = 0; index < length; ++index) { |
|||
auto bit = start + index; |
|||
const auto byte = bit / 8; |
|||
bit %= 8; |
|||
if ((raw[byte] & kMask[bit]) == 0 ) { |
|||
return false; |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
std::string A2lHelper::GetStem(const std::string& path) { |
|||
// First parse out the file name
|
|||
const auto last_back_pos = path.find_last_of('\\'); |
|||
const auto back_pos = last_back_pos != std::string::npos; |
|||
|
|||
const auto last_forward_pos = path.find_last_of('/'); |
|||
const auto forward_pos = last_forward_pos != std::string::npos; |
|||
|
|||
std::string filename; |
|||
if (back_pos && forward_pos) { |
|||
if ( last_back_pos > last_forward_pos) { |
|||
// Use backward slash position
|
|||
filename = path.substr(last_back_pos + 1); |
|||
} else { |
|||
// Use forward slash position
|
|||
filename = path.substr(last_forward_pos + 1); |
|||
} |
|||
} else if (back_pos) { |
|||
filename = path.substr(last_back_pos + 1); |
|||
} else if (forward_pos) { |
|||
filename = path.substr(last_forward_pos + 1); |
|||
} else { |
|||
filename = path; |
|||
} |
|||
// Strip out the extension
|
|||
std::string stem; |
|||
const auto last_dot_pos = filename.find_last_of('.'); |
|||
if (last_dot_pos != std::string::npos) { |
|||
stem = filename.substr(0,last_dot_pos); |
|||
} else { |
|||
stem = filename; |
|||
} |
|||
|
|||
return stem; |
|||
} |
|||
|
|||
bool A2lHelper::FileExist(const std::string& path) { |
|||
std::ifstream temp(path); |
|||
return temp.good(); |
|||
} |
|||
|
|||
bool A2lHelper::IsLittleEndian() { |
|||
constexpr int temp = 1; |
|||
return *((const int8_t*) &temp) == 1; |
|||
} |
|||
|
|||
std::string A2lHelper::ParseIfDataProtocol(const std::string& input) { |
|||
constexpr std::string_view begin = "/begin"; |
|||
constexpr std::string_view if_data = "IF_DATA"; |
|||
size_t pos = 0; |
|||
if (strncmp(input.data(), begin.data(), begin.size()) != 0) { |
|||
return {}; |
|||
} |
|||
pos += begin.size(); |
|||
while (std::isspace(input[pos])) { |
|||
++pos; |
|||
} |
|||
if (strncmp(input.data() + pos, if_data.data(), if_data.size()) != 0) { |
|||
return {}; |
|||
} |
|||
pos += if_data.size(); |
|||
while (std::isspace(input[pos])) { |
|||
++pos; |
|||
} |
|||
std::ostringstream protocol; |
|||
while (input[pos] != '\0' && !std::isspace(input[pos])) { |
|||
protocol << input[pos]; |
|||
++pos; |
|||
} |
|||
return protocol.str(); |
|||
} |
|||
|
|||
int A2lHelper::stricmp(const char *__s1, const char *__s2) { |
|||
#if (_MSC_VER) |
|||
return _stricmp(__s1, __s2); |
|||
#else |
|||
return strcasecmp(__s1, __s2); |
|||
#endif |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
#pragma once |
|||
|
|||
#include <cstdint> |
|||
#include <string> |
|||
#include <vector> |
|||
|
|||
namespace a2l { |
|||
class A2lHelper { |
|||
public: |
|||
static void DoubleToRaw(bool little_endian, size_t start, size_t length, |
|||
double value, uint8_t* dest); |
|||
|
|||
static void FloatToRaw(bool little_endian, size_t start, size_t length, |
|||
float value, uint8_t* dest); |
|||
|
|||
static void SignedToRaw(bool little_endian, size_t start, size_t length, |
|||
int64_t value, uint8_t* raw); |
|||
|
|||
static void UnsignedToRaw(bool little_endian, size_t start, size_t length, |
|||
uint64_t value, uint8_t* raw); |
|||
|
|||
static std::vector<uint8_t> RawToByteArray(size_t start, size_t length, |
|||
const unsigned char* raw); |
|||
|
|||
static double RawToDouble(bool little_endian, size_t start, size_t length, |
|||
const unsigned char* raw); |
|||
|
|||
static float RawToFloat(bool little_endian, size_t start, size_t length, |
|||
const unsigned char* raw); |
|||
|
|||
static int64_t RawToSigned(bool little_endian, size_t start, size_t length, |
|||
const uint8_t* raw); |
|||
|
|||
static uint64_t RawToUnsigned(bool little_endian, size_t start, size_t length, |
|||
const uint8_t* raw); |
|||
|
|||
static void SetAllBits(size_t start, size_t length, uint8_t* raw); |
|||
|
|||
static bool IsAllBitsSet(size_t start, size_t length, const uint8_t* raw); |
|||
|
|||
static std::string GetStem(const std::string& path); |
|||
|
|||
static bool FileExist(const std::string& path); |
|||
|
|||
static bool IsLittleEndian(); |
|||
|
|||
static std::string ParseIfDataProtocol(const std::string& input); |
|||
static int stricmp(const char *__s1, const char *__s2); |
|||
}; |
|||
|
|||
} // end namespace
|
|||
@ -0,0 +1,32 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/a2lobject.h" |
|||
#include <sstream> |
|||
#include <algorithm> |
|||
#include "a2lhelper.h" |
|||
namespace a2l { |
|||
|
|||
void A2lObject::AddIfData(const std::string& input) { |
|||
const auto protocol = A2lHelper::ParseIfDataProtocol(input); |
|||
if (protocol.empty()) { |
|||
return; |
|||
} |
|||
if_data_list_.emplace(protocol,input); |
|||
} |
|||
|
|||
void A2lObject::AddAnnotation(const A2lAnnotation& annotation) { |
|||
annotation_list_.emplace_back(annotation); |
|||
} |
|||
|
|||
bool A2lObject::HaveIfData(const std::string_view& protocol) const { |
|||
return std::any_of(if_data_list_.cbegin(), if_data_list_.cend(), |
|||
[&] (const auto& itr) { |
|||
return itr.first == protocol; |
|||
}); |
|||
} |
|||
|
|||
} // end namespace a2l
|
|||
|
|||
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,14 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/a2lproject.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
void A2lProject::AddModule(std::unique_ptr<Module>& module) { |
|||
module_list_.emplace(module->Name(), std::move(module)); |
|||
} |
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,523 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2lscanner.h" |
|||
#include <filesystem> |
|||
#include <sstream> |
|||
#include <array> |
|||
#include <cstring> |
|||
#include <boost/locale.hpp> |
|||
#include <boost/endian.hpp> |
|||
#include "a2l/a2lfile.h" |
|||
#include "a2lhelper.h" |
|||
|
|||
using namespace std::filesystem; |
|||
using namespace boost::locale; |
|||
using namespace boost::endian; |
|||
|
|||
namespace { |
|||
|
|||
constexpr std::array<std::string_view,5> BomList = { |
|||
std::string_view("\x00\x00\xFE\xFF",4), |
|||
std::string_view("\xFF\xFE\x00\x00",4), |
|||
std::string_view("\xFE\xFF",2), |
|||
std::string_view("\xFF\xFE",2), |
|||
std::string_view("\xEF\xBB\xBF", 3) |
|||
}; |
|||
|
|||
enum class FileEncoding : int { |
|||
UTF32_BE = 0, |
|||
UTF32_LE, |
|||
UTF16_BE, |
|||
UTF16_LE, |
|||
UTF8, |
|||
ASCII |
|||
}; |
|||
|
|||
} |
|||
|
|||
namespace a2l { |
|||
|
|||
A2lScanner::A2lScanner(std::istringstream& message) |
|||
: a2lFlexLexer(&message), yylval(nullptr) { |
|||
// I add a dummy file item onto the stack. This item is used to store
|
|||
// the current stack state pointer in case of an include file.
|
|||
file_stack_.emplace_back(""); |
|||
} |
|||
|
|||
void A2lScanner::ReadAndConvertFile(const std::string& filename, std::istringstream& utf8_stream) { |
|||
const std::u8string file_utf8 = |
|||
reinterpret_cast<const char8_t*>(filename.c_str()); |
|||
const path file_path(file_utf8); |
|||
|
|||
// Check if the file exist
|
|||
if (!exists(file_path)) { |
|||
std::ostringstream error; |
|||
error << "The file doesn't exist. File: " << filename; |
|||
throw std::runtime_error(error.str()); |
|||
} |
|||
|
|||
// Check file size
|
|||
const auto size = file_size(file_path); |
|||
if (size <= 4) { |
|||
std::ostringstream error; |
|||
error << "The file is empty. File: " << filename; |
|||
throw std::runtime_error(error.str()); |
|||
} |
|||
|
|||
std::string temp_buffer; |
|||
std::ifstream file(file_path, std::ios::binary | std::ios::in); |
|||
auto itr = std::istreambuf_iterator<char>(file); |
|||
auto end = std::istreambuf_iterator<char>(); |
|||
temp_buffer.append(itr, end); |
|||
file.close(); |
|||
|
|||
auto encoding = FileEncoding::ASCII; |
|||
int enc = 0; |
|||
for (const auto& bom : BomList) { |
|||
if (temp_buffer.compare(0,bom.length(), bom) == 0) { |
|||
encoding = static_cast<FileEncoding>(enc); |
|||
temp_buffer = temp_buffer.substr(bom.length()); |
|||
break; |
|||
} |
|||
++enc; |
|||
} |
|||
|
|||
switch (encoding) { |
|||
case FileEncoding::UTF32_BE:{ |
|||
const auto size32 = temp_buffer.length() / 4; |
|||
std::u32string temp32(size32, 0); |
|||
for (size_t index = 0; index < size32; ++index) { |
|||
const auto input = |
|||
static_cast<uint32_t>(static_cast<uint8_t>(temp_buffer[index * 4])); |
|||
temp32[index] = big_to_native(input); |
|||
} |
|||
utf8_stream.str( conv::to_utf<char>(temp_buffer,"UTF-32")); |
|||
break; |
|||
} |
|||
|
|||
case FileEncoding::UTF32_LE:{ |
|||
const auto size32 = temp_buffer.length() / 4; |
|||
std::u32string temp32(size32, 0); |
|||
for (size_t index = 0; index < size32; ++index) { |
|||
const auto input = |
|||
static_cast<uint32_t>(static_cast<uint8_t>(temp_buffer[index * 4])); |
|||
temp32[index] = little_to_native(input); |
|||
} |
|||
utf8_stream.str( conv::to_utf<char>(temp_buffer,"UTF-32")); |
|||
break; |
|||
} |
|||
|
|||
case FileEncoding::UTF16_BE:{ |
|||
const auto size16 = temp_buffer.length() / 2; |
|||
std::u16string temp16(size16, 0); |
|||
for (size_t index = 0; index < size16; ++index) { |
|||
const auto input = |
|||
static_cast<uint16_t>(static_cast<uint8_t>(temp_buffer[index * 2])); |
|||
temp16[index] = big_to_native(input); |
|||
} |
|||
utf8_stream.str( conv::to_utf<char>(temp_buffer,"UTF-16") ); |
|||
break; |
|||
} |
|||
|
|||
case FileEncoding::UTF16_LE:{ |
|||
const auto size16 = temp_buffer.length() / 2; |
|||
std::u16string temp16(size16, 0); |
|||
for (size_t index = 0; index < size16; ++index) { |
|||
const auto input = |
|||
static_cast<uint16_t>(static_cast<uint8_t>(temp_buffer[index * 2])); |
|||
temp16[index] = little_to_native(input); |
|||
} |
|||
utf8_stream.str(conv::to_utf<char>(temp_buffer,"UTF-16")); |
|||
break; |
|||
} |
|||
|
|||
case FileEncoding::ASCII: |
|||
utf8_stream.str(conv::to_utf<char>(temp_buffer,"ISO-8859-1")); |
|||
break; |
|||
|
|||
case FileEncoding::UTF8: |
|||
default: |
|||
utf8_stream.str(temp_buffer); |
|||
break; |
|||
} |
|||
|
|||
} |
|||
|
|||
std::string A2lScanner::ReadA2ML() { |
|||
std::ostringstream a2ml_text; |
|||
a2ml_text << yytext; |
|||
|
|||
std::string match; |
|||
constexpr std::string_view end_a2ml = "/endA2ML"; |
|||
for (auto data = yyinput(); data != '\0'; data = yyinput()) { |
|||
a2ml_text << static_cast<char>(data); |
|||
if (std::isspace(data)) { |
|||
continue; |
|||
} |
|||
match.push_back(static_cast<char>(data)); |
|||
if (match == end_a2ml) { |
|||
break; |
|||
} |
|||
while (match.size() >= end_a2ml.size()) { |
|||
match.erase(0,1); |
|||
} |
|||
} |
|||
return a2ml_text.str(); |
|||
} |
|||
|
|||
std::string A2lScanner::ReadIfData() { |
|||
std::ostringstream if_data_text; |
|||
if_data_text << yytext; |
|||
|
|||
std::string match; |
|||
constexpr std::string_view end_if_data = "/endIF_DATA"; |
|||
for (auto data = yyinput(); data != '\0'; data = yyinput()) { |
|||
if_data_text << static_cast<char>(data); |
|||
if (std::isspace(data)) { |
|||
continue; |
|||
} |
|||
match.push_back(static_cast<char>(data)); |
|||
if (match == end_if_data) { |
|||
break; |
|||
} |
|||
while (match.size() >= end_if_data.size()) { |
|||
match.erase(0,1); |
|||
} |
|||
} |
|||
return if_data_text.str(); |
|||
} |
|||
|
|||
std::string A2lScanner::ReadIfDataSingleLine() { |
|||
std::ostringstream if_data_text; |
|||
if_data_text << "/begin " << yytext; |
|||
|
|||
constexpr std::string_view end_if_data = "/endIF_DATA"; |
|||
for (auto data = yyinput(); |
|||
data != '\0' && data != '\n' && data != '\r'; |
|||
data = yyinput()) { |
|||
if_data_text << static_cast<char>(data); |
|||
} |
|||
if_data_text << " " << end_if_data; |
|||
return if_data_text.str(); |
|||
} |
|||
|
|||
std::string A2lScanner::ReadIfDataMultiLine() { |
|||
std::ostringstream if_data_text; |
|||
if_data_text << "/begin IF_DATA"; |
|||
|
|||
constexpr std::string_view end_if_data = "/endIF_DATA"; |
|||
int state = 0; // The state becomes -1 at end of string
|
|||
for (auto data = yyinput(); data != '\0'; data = yyinput()) { |
|||
switch (data) { |
|||
case '{': |
|||
++state; |
|||
break; |
|||
case '}': |
|||
--state; |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
if (state < 0) { |
|||
break; |
|||
} |
|||
if_data_text << static_cast<char>(data); |
|||
} |
|||
if_data_text << " " << end_if_data; |
|||
return if_data_text.str(); |
|||
} |
|||
|
|||
void A2lScanner::SkipUntil(char end_char) { |
|||
for (auto data = yyinput(); |
|||
data != '\0' && data != end_char; |
|||
data = yyinput()) { |
|||
} |
|||
} |
|||
|
|||
Module& A2lScanner::CurrentModule() { |
|||
if (!module_) { |
|||
module_ = std::make_unique<Module>(); |
|||
} |
|||
return *module_; |
|||
} |
|||
|
|||
AxisDescr& A2lScanner::CurrentAxisDescr() { |
|||
if (!axis_descr_) { |
|||
axis_descr_ = std::make_unique<AxisDescr>(); |
|||
} |
|||
return *axis_descr_; |
|||
} |
|||
|
|||
AxisPts& A2lScanner::CurrentAxisPts() { |
|||
if (!axis_pts_) { |
|||
axis_pts_ = std::make_unique<AxisPts>(); |
|||
} |
|||
return *axis_pts_; |
|||
} |
|||
|
|||
Blob& A2lScanner::CurrentBlob() { |
|||
if (!blob_) { |
|||
blob_ = std::make_unique<Blob>(); |
|||
} |
|||
return *blob_; |
|||
} |
|||
|
|||
Characteristic& A2lScanner::CurrentCharacteristic() { |
|||
if (!characteristic_) { |
|||
characteristic_ = std::make_unique<Characteristic>(); |
|||
} |
|||
return *characteristic_; |
|||
} |
|||
|
|||
CompuMethod& A2lScanner::CurrentCompuMethod() { |
|||
if (!compu_method_) { |
|||
compu_method_ = std::make_unique<CompuMethod>(); |
|||
} |
|||
return *compu_method_; |
|||
} |
|||
|
|||
CompuTab& A2lScanner::CurrentCompuTab() { |
|||
if (!compu_tab_) { |
|||
compu_tab_ = std::make_unique<CompuTab>(); |
|||
} |
|||
return *compu_tab_; |
|||
} |
|||
|
|||
CompuVtab& A2lScanner::CurrentCompuVtab() { |
|||
if (!compu_vtab_) { |
|||
compu_vtab_ = std::make_unique<CompuVtab>(); |
|||
} |
|||
return *compu_vtab_; |
|||
} |
|||
|
|||
CompuVtabRange& A2lScanner::CurrentCompuVtabRange() { |
|||
if (!compu_vtab_range_) { |
|||
compu_vtab_range_ = std::make_unique<CompuVtabRange>(); |
|||
} |
|||
return *compu_vtab_range_; |
|||
} |
|||
|
|||
Frame& A2lScanner::CurrentFrame() { |
|||
if (!frame_) { |
|||
frame_ = std::make_unique<Frame>(); |
|||
} |
|||
return *frame_; |
|||
} |
|||
|
|||
Function& A2lScanner::CurrentFunction() { |
|||
if (!function_) { |
|||
function_ = std::make_unique<Function>(); |
|||
} |
|||
return *function_; |
|||
} |
|||
|
|||
Group& A2lScanner::CurrentGroup() { |
|||
if (!group_) { |
|||
group_ = std::make_unique<Group>(); |
|||
} |
|||
return *group_; |
|||
} |
|||
|
|||
Instance& A2lScanner::CurrentInstance() { |
|||
if (!instance_) { |
|||
instance_ = std::make_unique<Instance>(); |
|||
} |
|||
return *instance_; |
|||
} |
|||
|
|||
Overwrite& A2lScanner::CurrentOverwrite() { |
|||
if (!overwrite_) { |
|||
overwrite_ = std::make_unique<Overwrite>(); |
|||
} |
|||
return *overwrite_; |
|||
} |
|||
|
|||
Measurement& A2lScanner::CurrentMeasurement() { |
|||
if (!measurement_) { |
|||
measurement_ = std::make_unique<Measurement>(); |
|||
} |
|||
return *measurement_; |
|||
} |
|||
|
|||
RecordLayout& A2lScanner::CurrentRecordLayout() { |
|||
if (!record_layout_) { |
|||
record_layout_ = std::make_unique<RecordLayout>(); |
|||
} |
|||
return *record_layout_; |
|||
} |
|||
|
|||
Transformer& A2lScanner::CurrentTransformer() { |
|||
if (!transformer_) { |
|||
transformer_ = std::make_unique<Transformer>(); |
|||
} |
|||
return *transformer_; |
|||
} |
|||
|
|||
AxisPts& A2lScanner::CurrentTypedefAxis() { |
|||
if (!typedef_axis_) { |
|||
typedef_axis_ = std::make_unique<AxisPts>(); |
|||
} |
|||
return *typedef_axis_; |
|||
} |
|||
|
|||
Blob& A2lScanner::CurrentTypedefBlob() { |
|||
if (!typedef_blob_) { |
|||
typedef_blob_ = std::make_unique<Blob>(); |
|||
typedef_blob_->AddressType(A2lAddressType::DIRECT); |
|||
} |
|||
return *typedef_blob_; |
|||
} |
|||
|
|||
Characteristic& A2lScanner::CurrentTypedefCharacteristic() { |
|||
if (!typedef_characteristic_) { |
|||
typedef_characteristic_ = std::make_unique<Characteristic>(); |
|||
} |
|||
return *typedef_characteristic_; |
|||
} |
|||
|
|||
Measurement& A2lScanner::CurrentTypedefMeasurement() { |
|||
if (!typedef_measurement_) { |
|||
typedef_measurement_ = std::make_unique<Measurement>(); |
|||
} |
|||
return *typedef_measurement_; |
|||
} |
|||
|
|||
Structure& A2lScanner::CurrentTypedefStructure() { |
|||
if (!typedef_structure_) { |
|||
typedef_structure_ = std::make_unique<Structure>(); |
|||
} |
|||
return *typedef_structure_; |
|||
} |
|||
|
|||
A2lStructureComponent& A2lScanner::CurrentStructureComponent() { |
|||
if (!structure_component_) { |
|||
structure_component_ = std::make_unique<A2lStructureComponent>(); |
|||
} |
|||
return *structure_component_; |
|||
} |
|||
|
|||
Unit& A2lScanner::CurrentUnit() { |
|||
if (!unit_) { |
|||
unit_ = std::make_unique<Unit>(); |
|||
} |
|||
return *unit_; |
|||
} |
|||
|
|||
A2lUserRight& A2lScanner::CurrentUserRight() { |
|||
if (!user_right_) { |
|||
user_right_ = std::make_unique<A2lUserRight>(); |
|||
} |
|||
return *user_right_; |
|||
} |
|||
|
|||
void A2lScanner::FixIncludeFile() { |
|||
// I shall read in "<file path>" but also <file_path> should work
|
|||
// Skip white space and '"' characters
|
|||
|
|||
std::ostringstream file_path; |
|||
for (auto data = yyinput(); data != '\0' ; data = yyinput()) { |
|||
if (std::isspace(data)) { |
|||
continue; |
|||
} |
|||
if (data == '"') { |
|||
continue; |
|||
} |
|||
file_path << static_cast<char>(data); |
|||
break; |
|||
} |
|||
|
|||
for (auto input = yyinput(); input != '\0' ; input = yyinput()) { |
|||
if (std::isspace(input)) { |
|||
break; |
|||
} |
|||
if (input == '"') { |
|||
break; |
|||
} |
|||
file_path << static_cast<char>(input); |
|||
} |
|||
|
|||
std::string include_file; |
|||
std::string file_extension; |
|||
try { |
|||
const path fullname(file_path.str()); |
|||
if (fullname.is_absolute() ) { |
|||
if (exists(fullname)) { |
|||
include_file = fullname.string(); |
|||
file_extension = fullname.extension().string(); |
|||
} else { |
|||
// File doesn't exists
|
|||
std::ostringstream err; |
|||
err << "File doesn't exist. File: " << fullname; |
|||
throw std::runtime_error(err.str()); |
|||
} |
|||
} else { |
|||
// Relative path assume the file should be relative the input_file
|
|||
path input_file(InputFile()); // Current filename with path
|
|||
input_file.replace_filename(fullname); |
|||
if (exists(input_file)) { |
|||
include_file = input_file.string(); |
|||
file_extension = input_file.extension().string(); |
|||
} else { |
|||
// File doesn't exists
|
|||
std::ostringstream err; |
|||
err << "File doesn't exist. File: " << InputFile(); |
|||
throw std::runtime_error(err.str()); |
|||
} |
|||
} |
|||
} |
|||
catch (const std::exception& error) { |
|||
std::ostringstream err; |
|||
err << "Include file path error. Error: " << error.what() << ", File: " << file_path.str(); |
|||
throw std::runtime_error(err.str()); |
|||
} |
|||
|
|||
// The included file exist but if the extension is A2L then
|
|||
// it could be an existing A2L but the current parser already defined a
|
|||
// PROJECT tag. To solve this try to parse the A2L file and if it succeeds,
|
|||
// merge in that MODULE into the module list of the other project.
|
|||
if (A2lHelper::stricmp(file_extension.c_str(), ".a2l") == 0) { |
|||
A2lFile temp_file; |
|||
temp_file.Filename(include_file); |
|||
const bool parse = temp_file.ParseFile(); |
|||
if (parse && parent_ != nullptr) { |
|||
// Move the project to the original project
|
|||
parent_->Merge(temp_file); |
|||
return; |
|||
} |
|||
|
|||
// Continue with plan B that includes the file according to the standard.
|
|||
} |
|||
// The include file exist. Store the current state and switch to the new file.
|
|||
// Note that the <<EOF>> function in the lexer file will restore the state to
|
|||
// the old one.
|
|||
FileItem& current_item = file_stack_.back(); |
|||
current_item.buffer_state = yy_buffer_stack[yy_buffer_stack_top]; |
|||
|
|||
// Switch to the include file
|
|||
file_stack_.emplace_back(include_file); |
|||
auto& new_stack = file_stack_.back(); |
|||
ReadAndConvertFile(new_stack.file, new_stack.utf8_stream); |
|||
new_stack.buffer_state = yy_create_buffer(new_stack.utf8_stream, 16384); |
|||
|
|||
a2lFlexLexer::yy_switch_to_buffer(new_stack.buffer_state); |
|||
|
|||
} |
|||
|
|||
void A2lScanner::InputFile(std::string filename) { |
|||
if (!file_stack_.empty()) { |
|||
file_stack_.back().file = std::move(filename); |
|||
} |
|||
} |
|||
|
|||
std::string A2lScanner::InputFile() const { |
|||
return file_stack_.empty() ? "" : file_stack_.back().file; |
|||
} |
|||
|
|||
void A2lScanner::Parent(A2lFile *parent) { |
|||
parent_ = parent; |
|||
} |
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,231 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
#pragma once |
|||
|
|||
#include <fstream> |
|||
#include <string> |
|||
#include <memory> |
|||
#include <utility> |
|||
#include <vector> |
|||
#include <sstream> |
|||
|
|||
#ifndef yyFlexLexerOnce |
|||
|
|||
#undef yyFlexLexer |
|||
#define yyFlexLexer a2lFlexLexer |
|||
#include <FlexLexer.h> |
|||
|
|||
#endif |
|||
|
|||
#include <map> |
|||
#include <memory> |
|||
#include <sstream> |
|||
#include <vector> |
|||
|
|||
#include "a2l/axisdescr.h" |
|||
#include "a2l/axispts.h" |
|||
#include "a2l/module.h" |
|||
#include "a2lparser.hpp" |
|||
#include "a2l/a2lfile.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
class A2lFile; |
|||
|
|||
class A2lScanner : public a2lFlexLexer { |
|||
public: |
|||
|
|||
struct FileItem{ |
|||
std::istringstream utf8_stream; ///< The file input converted to UTF8
|
|||
yy_buffer_state *buffer_state = nullptr; ///< Needed when switching state
|
|||
std::string file; ///< Filename including path.
|
|||
|
|||
explicit FileItem(std::string filename) : |
|||
file(std::move(filename)) { |
|||
} |
|||
}; |
|||
|
|||
explicit A2lScanner(std::istringstream& in); |
|||
|
|||
int a2llex(A2lParser::value_type* yylval); |
|||
|
|||
void InputFile( std::string filename); |
|||
[[nodiscard]] std::string InputFile() const; |
|||
|
|||
void Parent(A2lFile* parent); |
|||
|
|||
static void ReadAndConvertFile(const std::string& filename, std::istringstream& utf8_stream ); |
|||
|
|||
void LastError(const std::string& error) { last_error_ = error; } |
|||
[[nodiscard]] const std::string& LastError() const { return last_error_; } |
|||
|
|||
Module& CurrentModule(); |
|||
std::unique_ptr<Module>& ReleaseModule() { return module_; }; |
|||
|
|||
AxisDescr& CurrentAxisDescr(); |
|||
std::unique_ptr<AxisDescr>& ReleaseAxisDescr() { return axis_descr_; }; |
|||
|
|||
AxisPts& CurrentAxisPts(); |
|||
std::unique_ptr<AxisPts>& ReleaseAxisPts() { return axis_pts_; }; |
|||
|
|||
Blob& CurrentBlob(); |
|||
std::unique_ptr<Blob>& ReleaseBlob() { return blob_; }; |
|||
|
|||
Characteristic& CurrentCharacteristic(); |
|||
std::unique_ptr<Characteristic>& ReleaseCharacteristic() { |
|||
return characteristic_; |
|||
}; |
|||
|
|||
CompuMethod& CurrentCompuMethod(); |
|||
std::unique_ptr<CompuMethod>& ReleaseCompuMethod() { |
|||
return compu_method_; |
|||
}; |
|||
|
|||
CompuTab& CurrentCompuTab(); |
|||
std::unique_ptr<CompuTab>& ReleaseCompuTab() { |
|||
return compu_tab_; |
|||
}; |
|||
|
|||
CompuVtab& CurrentCompuVtab(); |
|||
std::unique_ptr<CompuVtab>& ReleaseCompuVtab() { |
|||
return compu_vtab_; |
|||
}; |
|||
|
|||
CompuVtabRange& CurrentCompuVtabRange(); |
|||
std::unique_ptr<CompuVtabRange>& ReleaseCompuVtabRange() { |
|||
return compu_vtab_range_; |
|||
}; |
|||
|
|||
Frame& CurrentFrame(); |
|||
std::unique_ptr<Frame>& ReleaseFrame() { |
|||
return frame_; |
|||
}; |
|||
|
|||
Function& CurrentFunction(); |
|||
std::unique_ptr<Function>& ReleaseFunction() { |
|||
return function_; |
|||
}; |
|||
|
|||
Group& CurrentGroup(); |
|||
std::unique_ptr<Group>& ReleaseGroup() { |
|||
return group_; |
|||
}; |
|||
|
|||
Instance& CurrentInstance(); |
|||
std::unique_ptr<Instance>& ReleaseInstance() { |
|||
return instance_; |
|||
}; |
|||
|
|||
Overwrite& CurrentOverwrite(); |
|||
std::unique_ptr<Overwrite>& ReleaseOverwrite() { |
|||
return overwrite_; |
|||
}; |
|||
|
|||
Measurement& CurrentMeasurement(); |
|||
std::unique_ptr<Measurement>& ReleaseMeasurement() { |
|||
return measurement_; |
|||
}; |
|||
|
|||
A2lBitOperation& CurrentBitOperation() { return bit_operation_; }; |
|||
|
|||
RecordLayout& CurrentRecordLayout(); |
|||
std::unique_ptr<RecordLayout>& ReleaseRecordLayout() { |
|||
return record_layout_; |
|||
}; |
|||
|
|||
Transformer& CurrentTransformer(); |
|||
std::unique_ptr<Transformer>& ReleaseTransformer() { |
|||
return transformer_; |
|||
}; |
|||
|
|||
AxisPts& CurrentTypedefAxis(); |
|||
std::unique_ptr<AxisPts>& ReleaseTypedefAxis() { |
|||
return typedef_axis_; |
|||
}; |
|||
|
|||
Blob& CurrentTypedefBlob(); |
|||
std::unique_ptr<Blob>& ReleaseTypedefBlob() { |
|||
return typedef_blob_; |
|||
}; |
|||
|
|||
Characteristic& CurrentTypedefCharacteristic(); |
|||
std::unique_ptr<Characteristic>& ReleaseTypedefCharacteristic() { |
|||
return typedef_characteristic_; |
|||
}; |
|||
|
|||
Measurement& CurrentTypedefMeasurement(); |
|||
std::unique_ptr<Measurement>& ReleaseTypedefMeasurement() { |
|||
return typedef_measurement_; |
|||
}; |
|||
|
|||
Structure& CurrentTypedefStructure(); |
|||
std::unique_ptr<Structure>& ReleaseTypedefStructure() { |
|||
return typedef_structure_; |
|||
}; |
|||
|
|||
A2lStructureComponent& CurrentStructureComponent(); |
|||
std::unique_ptr<A2lStructureComponent>& ReleaseStructureComponent() { |
|||
return structure_component_; |
|||
}; |
|||
|
|||
Unit& CurrentUnit(); |
|||
std::unique_ptr<Unit>& ReleaseUnit() { |
|||
return unit_; |
|||
}; |
|||
|
|||
A2lUserRight& CurrentUserRight(); |
|||
std::unique_ptr<A2lUserRight>& ReleaseUserRight() { |
|||
return user_right_; |
|||
}; |
|||
|
|||
A2lVarCriterion& VarCriterion() { return var_criterion_; }; |
|||
|
|||
[[nodiscard]] bool IsA2lFile() const { return found_; } |
|||
|
|||
private: |
|||
|
|||
std::vector<FileItem> file_stack_; ///< The file stack is main purpose is for include files handling
|
|||
A2lParser::semantic_type* yylval = nullptr; |
|||
A2lFile* parent_ = nullptr; ///< Parent is needed if I must merge an A2L file.
|
|||
std::string last_error_; |
|||
bool found_ = false; ///< Indicate that the PROJECT tag has been found in the file.
|
|||
|
|||
std::string ReadA2ML(); |
|||
std::string ReadIfData(); |
|||
std::string ReadIfDataSingleLine(); |
|||
std::string ReadIfDataMultiLine(); |
|||
|
|||
std::unique_ptr<Module> module_; ///< Current module
|
|||
std::unique_ptr<AxisDescr> axis_descr_; ///< Current axis descr
|
|||
std::unique_ptr<AxisPts> axis_pts_; ///< Current axis pts
|
|||
std::unique_ptr<Blob> blob_; ///< Current blob
|
|||
std::unique_ptr<Characteristic> characteristic_; ///< Current characteristic
|
|||
std::unique_ptr<CompuMethod> compu_method_; ///< Current Compu Method
|
|||
std::unique_ptr<CompuTab> compu_tab_; ///< Current COMPU TAB
|
|||
std::unique_ptr<CompuVtab> compu_vtab_; ///< Current COMPU VTAB
|
|||
std::unique_ptr<CompuVtabRange> compu_vtab_range_; ///< Current VTAB Range
|
|||
std::unique_ptr<Frame> frame_; ///< Current Frame
|
|||
std::unique_ptr<Function> function_; ///< Current Function
|
|||
std::unique_ptr<Group> group_; |
|||
std::unique_ptr<Instance> instance_; |
|||
std::unique_ptr<Overwrite> overwrite_; |
|||
std::unique_ptr<Measurement> measurement_; |
|||
A2lBitOperation bit_operation_ = {}; |
|||
std::unique_ptr<RecordLayout> record_layout_; |
|||
std::unique_ptr<Transformer> transformer_; |
|||
std::unique_ptr<AxisPts> typedef_axis_; |
|||
std::unique_ptr<Blob> typedef_blob_; |
|||
std::unique_ptr<Characteristic> typedef_characteristic_; |
|||
std::unique_ptr<Measurement> typedef_measurement_; |
|||
std::unique_ptr<Structure> typedef_structure_; |
|||
std::unique_ptr<A2lStructureComponent> structure_component_; |
|||
std::unique_ptr<Unit> unit_; |
|||
std::unique_ptr<A2lUserRight> user_right_; |
|||
A2lVarCriterion var_criterion_ = {}; |
|||
void SkipUntil(char end_char); |
|||
void FixIncludeFile(); |
|||
}; |
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,30 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/a2mlblock.h" |
|||
#include <sstream> |
|||
#include "a2mlscanner.h" |
|||
#include "a2mlparser.hpp" |
|||
|
|||
namespace a2l { |
|||
|
|||
A2mlBlock::A2mlBlock(const std::string& a2ml) { |
|||
try { |
|||
if (a2ml.empty()) { |
|||
throw std::runtime_error("Nothing to parse"); |
|||
} |
|||
std::istringstream temp(a2ml); |
|||
A2mlScanner scanner(temp); |
|||
A2mlParser parser(scanner); |
|||
parse_ = parser.parse() == 0; |
|||
last_error_ = scanner.LastError(); |
|||
block_list_ = scanner.BlockList(); |
|||
} catch (const std::exception& err) { |
|||
last_error_ = err.what(); |
|||
parse_ = false; |
|||
} |
|||
} |
|||
|
|||
} // namespace a2l
|
|||
File diff suppressed because it is too large
@ -0,0 +1,162 @@ |
|||
%top { |
|||
#include <cstdint> |
|||
#include <cctype> |
|||
|
|||
} |
|||
%{ |
|||
#include "a2mlscanner.h" |
|||
#undef YY_DECL |
|||
#define YY_DECL int a2l::A2mlScanner::a2mllex(a2l::A2mlParser::value_type* yy_value) |
|||
using token = a2l::A2mlParser::token; |
|||
%} |
|||
|
|||
%option prefix="a2ml" |
|||
%option 8bit |
|||
%option nounistd |
|||
%option noyywrap |
|||
%option debug |
|||
%option never-interactive |
|||
%option c++ |
|||
%option yyclass="a2l:A2mlScanner" |
|||
%option yylineno |
|||
%option noinput |
|||
%option nounput |
|||
|
|||
|
|||
ws [ \t\n\v\f\r]+ |
|||
signed_number [-+]?[0-9]+ |
|||
unsigned_number [0-9]+ |
|||
hexnumber 0x[0-9a-fA-F]+ |
|||
float_val [-+]?[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)? |
|||
ident [a-zA-Z_]([_a-zA-Z0-9.-]*)? |
|||
string (\"(\\.|[^\\"])*\")* |
|||
/* \"([^\"\\]|(\\.))*\" */ |
|||
nl [\n\r] |
|||
keyword [A-Z_0-9]+ |
|||
text_array ("char[")[0-9]+("]") |
|||
|
|||
%% |
|||
%{ |
|||
yylval = yy_value; |
|||
%} |
|||
|
|||
|
|||
"A2ML" { return token::A2ML; } |
|||
|
|||
"/begin" { return token::A2ML_BEGIN; } |
|||
"/end" { return token::A2ML_END; } |
|||
{text_array} { return token::TEXT_ARRAY; } |
|||
|
|||
"(" { return token::MEM_BEGIN; } |
|||
")*" { return token::MEM_END; } |
|||
") *" { return token::MEM_END; } |
|||
|
|||
"block" { return token::BLOCK; } |
|||
"taggedunion" { return token::TAGGED_UNION; } |
|||
"taggedstruct" { return token::TAGGED_STRUCT; } |
|||
"{" { return token::BLOCK_BEGIN; } |
|||
"}" { return token::BLOCK_END; } |
|||
|
|||
"[" { return token::ARRAY_BEGIN; } |
|||
"]" { return token::ARRAY_END; } |
|||
";" { return token::DEF_END; } |
|||
"=" { return token::EQUAL; } |
|||
"struct" { return token::STRUCT; } |
|||
"char" { return token::CHAR; } |
|||
"int" { return token::INT; } |
|||
"long" { return token::LONG; } |
|||
"int64" { return token::INT64; } |
|||
"uchar" { return token::UCHAR; } |
|||
"uint" { return token::UINT; } |
|||
"uint64" { return token::UINT64; } |
|||
"ulong" { return token::ULONG; } |
|||
"double" { return token::DOUBLE; } |
|||
"float" { return token::FLOAT; } |
|||
"enum" { return token::ENUM; } |
|||
|
|||
|
|||
|
|||
{ident} { |
|||
std::string temp(yytext); |
|||
if (yylval != nullptr) { |
|||
yylval->emplace<std::string>(temp); |
|||
} |
|||
return token::IDENT; |
|||
} |
|||
|
|||
{string} { |
|||
const size_t len = strlen(yytext); |
|||
std::string temp; |
|||
if (len > 2) { |
|||
temp = yytext + 1; |
|||
temp.pop_back(); |
|||
} |
|||
yylval->emplace<std::string>(temp); |
|||
return token::STRING; |
|||
} |
|||
|
|||
{signed_number} { |
|||
int64_t temp = 0; |
|||
try { |
|||
temp = std::stoll(yytext); |
|||
} catch (const std::exception& ) { |
|||
|
|||
} |
|||
yylval->emplace<int64_t>(temp); |
|||
return token::CONSTANT; |
|||
} |
|||
{hexnumber} { |
|||
uint64_t address = 0; |
|||
for ( size_t index = 0; yytext[ index ] != '\0'; ++index ) { |
|||
if ( index < 2 ) continue; |
|||
const char token = yytext[index]; |
|||
switch ( token ) { |
|||
case '0': |
|||
case '1': |
|||
case '2': |
|||
case '3': |
|||
case '4': |
|||
case '5': |
|||
case '6': |
|||
case '7': |
|||
case '8': |
|||
case '9': |
|||
address *= 16; |
|||
address += token - '0'; |
|||
break; |
|||
|
|||
case 'A': |
|||
case 'B': |
|||
case 'C': |
|||
case 'D': |
|||
case 'E': |
|||
case 'F': |
|||
address *= 16; |
|||
address += token - 'A' + 10; |
|||
break; |
|||
|
|||
case 'a': |
|||
case 'b': |
|||
case 'c': |
|||
case 'd': |
|||
case 'e': |
|||
case 'f': |
|||
address *= 16; |
|||
address += token - 'a' + 10; |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
yylval->emplace<int64_t>(static_cast<int64_t>(address)); |
|||
return token::CONSTANT; |
|||
} |
|||
|
|||
[/][*][^*]*[*]+([^*/][^*]*[*]+)*[/] { } /* Multi line comments */ |
|||
"//".* { /* Single line comment */ } |
|||
{ws} {} |
|||
. {} |
|||
%% |
|||
|
|||
@ -0,0 +1,102 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/a2mlobject.h" |
|||
#include <sstream> |
|||
#include <string_view> |
|||
|
|||
namespace a2l { |
|||
|
|||
A2mlObject::A2mlObject(A2mlTypeName type) |
|||
: type_(type) { |
|||
|
|||
} |
|||
std::string_view A2mlObject::TypeAsString() const { |
|||
switch (type_) { |
|||
case A2mlTypeName::PREDEFINED: return "PREDEFINED"; |
|||
case A2mlTypeName::STRUCT: return "STRUCT"; |
|||
case A2mlTypeName::TAGGED_STRUCT: return "TAGGED STRUCT"; |
|||
case A2mlTypeName::TAGGED_UNION: return "TAGGED UNION"; |
|||
case A2mlTypeName::ENUMERATE: return "ENUMERATE"; |
|||
case A2mlTypeName::BLOCK: return "BLOCK"; |
|||
default: |
|||
break; |
|||
} |
|||
return ""; |
|||
} |
|||
|
|||
std::string_view A2mlObject::DataTypeAsString() const { |
|||
switch (data_type_) { |
|||
case A2mlDataType::CHAR: return "char"; |
|||
case A2mlDataType::INT: return "int"; |
|||
case A2mlDataType::LONG: return "long"; |
|||
case A2mlDataType::INT64: return "int64"; |
|||
case A2mlDataType::UCHAR: return "uchar"; |
|||
case A2mlDataType::UINT: return "uint"; |
|||
case A2mlDataType::ULONG: return "ulong"; |
|||
case A2mlDataType::UINT64: return "uint64"; |
|||
case A2mlDataType::DOUBLE: return "double"; |
|||
case A2mlDataType::FLOAT: return "float"; |
|||
case A2mlDataType::TEXT_ARRAY: return "string"; |
|||
default: |
|||
break; |
|||
|
|||
} |
|||
return {}; |
|||
} |
|||
|
|||
std::string A2mlObject::AsString() const { |
|||
std::ostringstream temp; |
|||
switch (type_) { |
|||
case A2mlTypeName::PREDEFINED: |
|||
if (!tag_.empty()) { |
|||
temp << "\"" << tag_ << "\"" << " "; |
|||
} |
|||
if (!ident_.empty()) { |
|||
temp << ident_ << " "; |
|||
} |
|||
temp << DataTypeAsString(); |
|||
break; |
|||
|
|||
case A2mlTypeName::ENUMERATE: |
|||
temp << TypeAsString() << " "; |
|||
if (!tag_.empty()) { |
|||
temp << "\"" << tag_ << "\"" << " "; |
|||
} |
|||
if (!ident_.empty()) { |
|||
temp << ident_ << " "; |
|||
} |
|||
if (!enumerate_list_.empty()) { |
|||
temp << DataTypeAsString() << " {" << std::endl; |
|||
for (const auto& [key, value] : enumerate_list_) { |
|||
temp << value << " = " << key << std::endl; |
|||
} |
|||
temp << "}"; |
|||
} |
|||
break; |
|||
|
|||
default: |
|||
temp << TypeAsString() << " "; |
|||
if (!tag_.empty()) { |
|||
temp << "\"" << tag_ << "\"" << " "; |
|||
} |
|||
if (!ident_.empty()) { |
|||
temp << ident_ << " "; |
|||
} |
|||
if (!member_list_.empty()) { |
|||
temp << "{" << std::endl; |
|||
for (const auto& object : member_list_) { |
|||
temp << object.AsString(); |
|||
} |
|||
temp << "}"; |
|||
} |
|||
break; |
|||
} |
|||
|
|||
temp << std::endl; |
|||
return temp.str(); |
|||
} |
|||
|
|||
} // namespace a2l
|
|||
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,326 @@ |
|||
%require "3.2" |
|||
%language "c++" |
|||
|
|||
|
|||
%define api.prefix {a2ml} |
|||
%define api.namespace {a2l} |
|||
%define api.parser.class {A2mlParser} |
|||
|
|||
|
|||
%code requires { |
|||
#include <string> |
|||
#include <vector> |
|||
#include <map> |
|||
#include <utility> |
|||
#include "a2l/a2mlobject.h" |
|||
|
|||
namespace a2l { |
|||
class A2mlScanner; |
|||
} |
|||
|
|||
} |
|||
|
|||
%parse-param { a2l::A2mlScanner &scanner } |
|||
|
|||
|
|||
%code { |
|||
#include <sstream> |
|||
#include "a2mlscanner.h" |
|||
|
|||
|
|||
#include "a2lhelper.h" |
|||
#include <limits> |
|||
|
|||
#undef yylex |
|||
#define yylex scanner.a2mllex |
|||
} |
|||
|
|||
%define api.value.type variant |
|||
|
|||
%token A2ML_BEGIN |
|||
%token A2ML_END |
|||
%token A2ML |
|||
%token ARRAY_BEGIN |
|||
%token ARRAY_END |
|||
%token BLOCK |
|||
%token BLOCK_BEGIN |
|||
%token BLOCK_END |
|||
%token CHAR |
|||
%token <int64_t> CONSTANT |
|||
%token DEF_END |
|||
%token DOUBLE |
|||
%token ENUM |
|||
%token EQUAL |
|||
%token <double> FLOAT |
|||
%token <std::string> IDENT |
|||
%token IF_DATA |
|||
%token INT |
|||
%token INT64 |
|||
%token LONG |
|||
%token MEM_BEGIN |
|||
%token MEM_END |
|||
%token <std::string> STRING |
|||
%token STRUCT |
|||
%token TAGGED_STRUCT |
|||
%token TAGGED_UNION |
|||
%token TEXT_ARRAY |
|||
%token UCHAR |
|||
%token UINT |
|||
%token UINT64 |
|||
%token ULONG |
|||
|
|||
%nterm <std::pair<int64_t, std::string>> enumerator |
|||
%nterm <a2l::A2mlEnumerateList> enumerator_list |
|||
%nterm <std::string> identifier |
|||
%nterm <std::string> keyword |
|||
%nterm <a2l::A2mlDataType> predefined_type_name |
|||
%nterm <std::string> tag |
|||
%nterm <a2l::A2mlObject> type_name |
|||
%nterm <a2l::A2mlObject> type_definition |
|||
%nterm <a2l::A2mlObject> block_definition |
|||
%nterm <a2l::A2mlObject> enum_type_name |
|||
%nterm <a2l::A2mlObject> struct_type_name |
|||
%nterm <a2l::A2mlObject> member |
|||
%nterm <a2l::A2mlMemberList> struct_member_list |
|||
%nterm <a2l::A2mlObject> struct_member |
|||
%nterm <a2l::A2mlObject> taggedstruct_type_name |
|||
%nterm <a2l::A2mlMemberList> taggedstruct_member_list |
|||
%nterm <a2l::A2mlObject> taggedstruct_member |
|||
%nterm <a2l::A2mlObject> taggedstruct_definition |
|||
%nterm <a2l::A2mlObject> taggedunion_type_name |
|||
%nterm <a2l::A2mlMemberList> taggedunion_member_list |
|||
%nterm <a2l::A2mlObject> taggedunion_member |
|||
%nterm <a2l::A2mlObject> declaration |
|||
%nterm <a2l::A2mlMemberList> declaration_list |
|||
|
|||
%start a2ml_block |
|||
|
|||
%% |
|||
|
|||
a2ml_block: %empty |
|||
| A2ML_BEGIN A2ML declaration_list A2ML_END A2ML { |
|||
scanner.BlockList($3); |
|||
}; |
|||
|
|||
declaration_list: declaration { |
|||
$$ = A2mlMemberList(); |
|||
$$.emplace_back($1); |
|||
} |
|||
| declaration_list declaration { |
|||
$$ = $1; |
|||
$$.emplace_back($2); |
|||
}; |
|||
|
|||
declaration: type_definition DEF_END { $$ = $1; } |
|||
| block_definition DEF_END { $$ = $1; }; |
|||
|
|||
type_definition: type_name { $$ = $1;}; |
|||
|
|||
type_name : predefined_type_name { |
|||
$$ = A2mlObject(A2mlTypeName::PREDEFINED); |
|||
$$.DataType($1); |
|||
} |
|||
| struct_type_name { |
|||
$$ = $1; |
|||
} |
|||
| taggedstruct_type_name { |
|||
$$ = $1; |
|||
} |
|||
| taggedunion_type_name { |
|||
$$ = $1; |
|||
} |
|||
| enum_type_name { |
|||
$$ = $1; |
|||
}; |
|||
|
|||
predefined_type_name: CHAR { $$ = A2mlDataType::CHAR;} |
|||
| INT { $$ = A2mlDataType::INT;} |
|||
| LONG { $$ = A2mlDataType::LONG;} |
|||
| INT64 { $$ = A2mlDataType::INT64;} |
|||
| UCHAR { $$ = A2mlDataType::UCHAR;} |
|||
| UINT { $$ = A2mlDataType::UINT;} |
|||
| UINT64 { $$ = A2mlDataType::UINT64;} |
|||
| ULONG { $$ = A2mlDataType::ULONG;} |
|||
| DOUBLE { $$ = A2mlDataType::DOUBLE;} |
|||
| FLOAT { $$ = A2mlDataType::FLOAT;} |
|||
| TEXT_ARRAY { $$ = A2mlDataType::TEXT_ARRAY;}; |
|||
|
|||
|
|||
block_definition: BLOCK tag member { |
|||
$$ = A2mlObject(A2mlTypeName::BLOCK); |
|||
$$.Tag($2); |
|||
$$.MemberList().emplace_back($3); |
|||
} |
|||
| BLOCK tag MEM_BEGIN member MEM_END { |
|||
$$ = A2mlObject(A2mlTypeName::BLOCK); |
|||
$$.Tag($2); |
|||
$$.MemberList().emplace_back($4); |
|||
}; |
|||
|
|||
|
|||
enum_type_name : ENUM identifier BLOCK_BEGIN enumerator_list BLOCK_END { |
|||
$$ = A2mlObject(A2mlTypeName::ENUMERATE); |
|||
$$.Ident($2); |
|||
$$.EnumerateList($4); |
|||
} |
|||
| ENUM IDENT { |
|||
$$ = A2mlObject(A2mlTypeName::ENUMERATE); |
|||
$$.Ident($2); |
|||
}; |
|||
|
|||
enumerator_list: enumerator { |
|||
A2mlEnumerateList list; |
|||
auto& enumerator = $1; |
|||
const auto itr = list.find(enumerator.first); |
|||
if (itr == list.cend() ) { |
|||
list.emplace(enumerator.first, enumerator.second); |
|||
} else { |
|||
// Change key |
|||
auto key = list.rbegin()->first; |
|||
++key; |
|||
list.emplace(key, enumerator.second); |
|||
} |
|||
$$ = list; |
|||
} |
|||
| enumerator_list enumerator { |
|||
auto& list = $1; |
|||
auto& enumerator = $2; |
|||
const auto itr = list.find(enumerator.first); |
|||
if (itr == list.cend() ) { |
|||
list.emplace(enumerator.first, enumerator.second); |
|||
} else { |
|||
// Change key |
|||
auto key = list.rbegin()->first; |
|||
++key; |
|||
list.emplace(key, enumerator.second); |
|||
} |
|||
$$ = list; |
|||
}; |
|||
|
|||
enumerator: keyword { |
|||
$$.first = 0; |
|||
$$.second = $1; |
|||
} |
|||
| keyword EQUAL CONSTANT { |
|||
$$.first = $3; |
|||
$$.second = $1; |
|||
}; |
|||
|
|||
struct_type_name: STRUCT identifier BLOCK_BEGIN struct_member_list BLOCK_END { |
|||
$$ = A2mlObject(A2mlTypeName::STRUCT); |
|||
$$.Ident($2); |
|||
$$.MemberList($4); |
|||
} |
|||
| STRUCT IDENT { |
|||
$$ = A2mlObject(A2mlTypeName::STRUCT); |
|||
$$.Ident($2); |
|||
}; |
|||
|
|||
struct_member_list: %empty {} |
|||
| struct_member_list struct_member { |
|||
$$ = $1; |
|||
$$.emplace_back($2); |
|||
}; |
|||
|
|||
struct_member: member DEF_END { |
|||
$$ = $1; |
|||
} |
|||
| MEM_BEGIN member MEM_END DEF_END { |
|||
$$ = $2; |
|||
}; |
|||
|
|||
member: type_name array_specifier { |
|||
$$ = $1; |
|||
// Todo Array specifier |
|||
}; |
|||
|
|||
array_specifier: %empty |
|||
| array_specifier ARRAY_BEGIN CONSTANT ARRAY_END; |
|||
|
|||
taggedstruct_type_name: TAGGED_STRUCT identifier BLOCK_BEGIN taggedstruct_member_list BLOCK_END { |
|||
$$ = A2mlObject(A2mlTypeName::TAGGED_STRUCT); |
|||
$$.Ident($2); |
|||
$$.MemberList($4); |
|||
} |
|||
| TAGGED_STRUCT IDENT { |
|||
$$ = A2mlObject(A2mlTypeName::TAGGED_STRUCT); |
|||
$$.Ident($2); |
|||
}; |
|||
|
|||
taggedstruct_member_list: taggedstruct_member { |
|||
$$ = A2mlMemberList(); |
|||
$$.emplace_back($1); |
|||
} |
|||
| taggedstruct_member_list taggedstruct_member { |
|||
$$ = $1; |
|||
$$.emplace_back($2); |
|||
}; |
|||
|
|||
taggedstruct_member: taggedstruct_definition DEF_END { $$ = $1; } |
|||
| MEM_BEGIN taggedstruct_definition MEM_END DEF_END { $$ = $2; } |
|||
| block_definition DEF_END {$$ = $1;} |
|||
| MEM_BEGIN block_definition MEM_END DEF_END { $$ = $2;}; |
|||
|
|||
taggedstruct_definition: tag { |
|||
$$ = A2mlObject(A2mlTypeName::UNKNOWN); |
|||
$$.Tag($1); |
|||
} |
|||
| tag member { |
|||
$$ = $2; |
|||
$$.Tag($1); |
|||
} |
|||
| tag MEM_BEGIN member MEM_END { |
|||
$$ = $3; |
|||
$$.Tag($1); |
|||
}; |
|||
|
|||
taggedunion_type_name: TAGGED_UNION identifier BLOCK_BEGIN taggedunion_member_list BLOCK_END { |
|||
$$ = A2mlObject(A2mlTypeName::TAGGED_UNION); |
|||
$$.Ident($2); |
|||
$$.MemberList( $4); |
|||
} |
|||
| TAGGED_UNION IDENT { |
|||
$$ = A2mlObject(A2mlTypeName::TAGGED_UNION); |
|||
$$.Ident($2); |
|||
}; |
|||
|
|||
taggedunion_member_list: taggedunion_member { |
|||
$$ = A2mlMemberList(); |
|||
$$.emplace_back($1); |
|||
} |
|||
| taggedunion_member_list taggedunion_member { |
|||
$$ = $1; |
|||
$$.emplace_back($2); |
|||
}; |
|||
|
|||
taggedunion_member: tag DEF_END { |
|||
$$ = A2mlObject(A2mlTypeName::UNKNOWN); |
|||
$$.Tag($1); |
|||
} |
|||
| tag member DEF_END { |
|||
$$ = $2; |
|||
$$.Tag($1); |
|||
} |
|||
| block_definition DEF_END { |
|||
$$ = $1; |
|||
}; |
|||
|
|||
keyword : STRING { $$ = $1; }; |
|||
|
|||
identifier: %empty {} |
|||
| IDENT { $$ = $1; }; |
|||
|
|||
tag: STRING { $$ = $1; }; |
|||
|
|||
%% |
|||
|
|||
void a2l::A2mlParser::error(const std::string& err) { |
|||
const auto line = scanner.lineno(); |
|||
// const auto column = scanner.YYLeng(); |
|||
const std::string near = scanner.YYText() != nullptr ? scanner.YYText() : ""; |
|||
std::ostringstream error; |
|||
error << "Parser error: " << err |
|||
<< ", Line: " << line |
|||
<< ", Near: " << near; |
|||
scanner.LastError(error.str()); |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2mlscanner.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
A2mlScanner::A2mlScanner(std::istream& message) |
|||
: a2mlFlexLexer(&message), yylval(nullptr) { |
|||
|
|||
} |
|||
|
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,50 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <fstream> |
|||
#include <string> |
|||
#include <memory> |
|||
|
|||
#ifndef yyFlexLexerOnce |
|||
|
|||
#undef yyFlexLexer |
|||
#define yyFlexLexer a2mlFlexLexer |
|||
#include <FlexLexer.h> |
|||
|
|||
#endif |
|||
|
|||
#include <map> |
|||
#include <memory> |
|||
#include <sstream> |
|||
#include <vector> |
|||
#include <stack> |
|||
#include "a2mlparser.hpp" |
|||
#include "a2l/a2mlobject.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
|
|||
class A2mlScanner : public a2mlFlexLexer { |
|||
public: |
|||
explicit A2mlScanner(std::istream& in); |
|||
int a2mllex(A2mlParser::value_type* yylval); |
|||
|
|||
void LastError(const std::string& error) { last_error_ = error; } |
|||
[[nodiscard]] const std::string& LastError() const { return last_error_; } |
|||
|
|||
void BlockList(const A2mlBlockList& list) { block_list_ = list; } |
|||
[[nodiscard]] const A2mlBlockList& BlockList() const { return block_list_; } |
|||
|
|||
|
|||
private: |
|||
A2mlParser::semantic_type* yylval = nullptr; |
|||
std::string last_error_; |
|||
std::vector<A2mlObject> block_list_; |
|||
|
|||
}; |
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,10 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/axisdescr.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,8 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/axispts.h" |
|||
|
|||
namespace a2l {} // namespace a2l
|
|||
@ -0,0 +1,10 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/blob.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,12 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/characteristic.h" |
|||
|
|||
namespace a2l { |
|||
void Characteristic::AddAxisDescr(std::unique_ptr<AxisDescr>& axis_descr) { |
|||
axis_descr_list_.emplace_back( std::move(axis_descr)); |
|||
} |
|||
} // end namespace a2l
|
|||
@ -0,0 +1,10 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/compumethod.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,28 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/computab.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
void CompuTab::DefaultValue(const std::string& value) { |
|||
default_value_ = value; |
|||
if (default_value_numeric_ == 0.0) { |
|||
try { |
|||
default_value_numeric_ = std::stod(value); |
|||
} catch (const std::exception& ) {} |
|||
} |
|||
} |
|||
|
|||
void CompuTab::DefaultValueNumeric(double value) { |
|||
default_value_numeric_ = value; |
|||
if (default_value_.empty()) { |
|||
try { |
|||
default_value_ = std::to_string(default_value_numeric_); |
|||
} catch (const std::exception&) {} |
|||
} |
|||
} |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,10 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/compuvtab.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,10 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/compuvtabrange.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,10 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/frame.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,3 @@ |
|||
//
|
|||
// Created by ihedv on 2023-08-29.
|
|||
//
|
|||
@ -0,0 +1,10 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/group.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,69 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/ifdatablock.h" |
|||
#include <sstream> |
|||
#include "ifdatascanner.h" |
|||
#include "ifdataparser.hpp" |
|||
|
|||
namespace a2l { |
|||
|
|||
IfDataBlock::IfDataBlock(const std::string& ifdata) { |
|||
try { |
|||
if (ifdata.empty()) { |
|||
throw std::runtime_error("Nothing to parse"); |
|||
} |
|||
std::istringstream temp(ifdata); |
|||
IfDataScanner scanner(temp); |
|||
IfDataParser parser(scanner); |
|||
parse_ = parser.parse() == 0; |
|||
last_error_ = scanner.LastError(); |
|||
protocol_ = scanner.Protocol(); |
|||
item_list_ = scanner.ItemList(); |
|||
} catch (const std::exception& err) { |
|||
last_error_ = err.what(); |
|||
parse_ = false; |
|||
} |
|||
} |
|||
|
|||
std::string IfDataBlock::AsString() const { |
|||
std::ostringstream temp; |
|||
temp << Protocol() << std::endl; |
|||
|
|||
for (const auto& item : item_list_) { |
|||
if (item.BlockName.empty() && item.ItemList.empty()) { |
|||
temp << "\t" << item.Value << std::endl; |
|||
} else { |
|||
temp << AsString(1,item); |
|||
} |
|||
} |
|||
temp << std::endl; |
|||
return temp.str(); |
|||
} |
|||
|
|||
std::string IfDataBlock::AsString(size_t tab_level, // NOLINT
|
|||
const IfDataItem& block_item) const { |
|||
std::ostringstream temp; |
|||
for (size_t level1 = 0; level1 < tab_level; ++level1 ) { |
|||
temp << "\t"; |
|||
} |
|||
temp << block_item.BlockName << std::endl; |
|||
|
|||
for (const auto& item : block_item.ItemList) { |
|||
if (item.BlockName.empty() && item.ItemList.empty()) { |
|||
for (size_t level1 = 0; level1 < tab_level; ++level1 ) { |
|||
temp << "\t"; |
|||
} |
|||
temp << "\t" << item.Value << std::endl; |
|||
} else { |
|||
temp << AsString(tab_level + 1,item); |
|||
} |
|||
} |
|||
temp << std::endl; |
|||
return temp.str(); |
|||
|
|||
} |
|||
|
|||
} // namespace a2l
|
|||
File diff suppressed because it is too large
@ -0,0 +1,149 @@ |
|||
%top { |
|||
#include <cstdint> |
|||
#include <cctype> |
|||
|
|||
} |
|||
%{ |
|||
#include "ifdatascanner.h" |
|||
#undef YY_DECL |
|||
#define YY_DECL int a2l::IfDataScanner::ifdatalex(a2l::IfDataParser::value_type* yy_value) |
|||
using token = a2l::IfDataParser::token; |
|||
%} |
|||
|
|||
%option prefix="ifdata" |
|||
%option 8bit |
|||
%option nounistd |
|||
%option noyywrap |
|||
%option debug |
|||
%option never-interactive |
|||
%option c++ |
|||
%option yyclass="a2l:IfDataScanner" |
|||
%option yylineno |
|||
%option noinput |
|||
%option nounput |
|||
|
|||
|
|||
ws [ \t\n\v\f\r]+ |
|||
signed_number [-+]?[0-9]+ |
|||
unsigned_number [0-9]+ |
|||
hexnumber 0x[0-9a-fA-F]+ |
|||
float_val [-+]?[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)? |
|||
ident [a-zA-Z_]([_a-zA-Z0-9.-]*)? |
|||
string (\"(\\.|[^\\"])*\")* |
|||
/* \"([^\"\\]|(\\.))*\" */ |
|||
nl [\n\r] |
|||
keyword [A-Z_0-9]+ |
|||
|
|||
|
|||
%% |
|||
%{ |
|||
yylval = yy_value; |
|||
%} |
|||
|
|||
"/begin" { return token::IF_DATA_BEGIN; } |
|||
"/end" { return token::IF_DATA_END; } |
|||
"IF_DATA" { return token::IF_DATA; } |
|||
{ident} { |
|||
if (yylval != nullptr) { |
|||
std::string temp(yytext); |
|||
yylval->emplace<std::string>(temp); |
|||
} |
|||
return token::IDENT; |
|||
} |
|||
|
|||
{string} { |
|||
const size_t len = strlen(yytext); |
|||
std::string temp; |
|||
if (len > 2) { |
|||
temp = yytext + 1; |
|||
temp.pop_back(); |
|||
} |
|||
yylval->emplace<std::string>(temp); |
|||
return token::STRING; |
|||
} |
|||
|
|||
{hexnumber} { |
|||
uint64_t address = 0; |
|||
for ( size_t index = 0; yytext[ index ] != '\0'; ++index ) { |
|||
if ( index < 2 ) continue; |
|||
const char token = yytext[index]; |
|||
switch ( token ) { |
|||
case '0': |
|||
case '1': |
|||
case '2': |
|||
case '3': |
|||
case '4': |
|||
case '5': |
|||
case '6': |
|||
case '7': |
|||
case '8': |
|||
case '9': |
|||
address *= 16; |
|||
address += token - '0'; |
|||
break; |
|||
|
|||
case 'A': |
|||
case 'B': |
|||
case 'C': |
|||
case 'D': |
|||
case 'E': |
|||
case 'F': |
|||
address *= 16; |
|||
address += token - 'A' + 10; |
|||
break; |
|||
|
|||
case 'a': |
|||
case 'b': |
|||
case 'c': |
|||
case 'd': |
|||
case 'e': |
|||
case 'f': |
|||
address *= 16; |
|||
address += token - 'a' + 10; |
|||
break; |
|||
|
|||
default: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
yylval->emplace<uint64_t>(address); |
|||
return token::HEX; |
|||
} |
|||
{unsigned_number} { |
|||
uint64_t temp = 0; |
|||
try { |
|||
temp = std::stoull(yytext); |
|||
} catch (const std::exception& ) { |
|||
|
|||
} |
|||
yylval->emplace<uint64_t>(temp); |
|||
return token::UINT; |
|||
} |
|||
{signed_number} { |
|||
int64_t temp = 0; |
|||
try { |
|||
temp = std::stoll(yytext); |
|||
} catch (const std::exception& ) { |
|||
|
|||
} |
|||
yylval->emplace<int64_t>(temp); |
|||
return token::INT; |
|||
} |
|||
{float_val} { |
|||
double temp = 0.0; |
|||
try { |
|||
temp = std::stod(yytext); |
|||
} catch (const std::exception&) { |
|||
|
|||
} |
|||
yylval->emplace<double>(temp); |
|||
return token::FLOAT; |
|||
} |
|||
|
|||
[/][*][^*]*[*]+([^*/][^*]*[*]+)*[/] { } /* Multi line comments */ |
|||
"//".* { /* Single line comment */ } |
|||
{ws} {} |
|||
. {} |
|||
%% |
|||
|
|||
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,121 @@ |
|||
%require "3.2" |
|||
%language "c++" |
|||
|
|||
|
|||
%define api.prefix {ifdata} |
|||
%define api.namespace {a2l} |
|||
%define api.parser.class {IfDataParser} |
|||
|
|||
|
|||
%code requires { |
|||
#include <string> |
|||
#include <vector> |
|||
#include <map> |
|||
#include <utility> |
|||
#include "a2l/ifdataitem.h" |
|||
|
|||
namespace a2l { |
|||
class IfDataScanner; |
|||
} |
|||
|
|||
} |
|||
|
|||
%parse-param { a2l::IfDataScanner &scanner } |
|||
|
|||
|
|||
%code { |
|||
#include <sstream> |
|||
#include "ifdatascanner.h" |
|||
|
|||
|
|||
#include "a2lhelper.h" |
|||
#include <limits> |
|||
|
|||
#undef yylex |
|||
#define yylex scanner.ifdatalex |
|||
} |
|||
|
|||
%define api.value.type variant |
|||
|
|||
%token IF_DATA_BEGIN |
|||
%token IF_DATA_END |
|||
%token <uint64_t> UINT |
|||
%token <uint64_t> HEX |
|||
%token <int64_t> INT |
|||
%token <double> FLOAT |
|||
%token <std::string> IDENT |
|||
%token IF_DATA |
|||
%token <std::string> STRING |
|||
|
|||
%nterm <std::string> protocol |
|||
%nterm <std::vector<a2l::IfDataItem>> block_data_list |
|||
%nterm <a2l::IfDataItem> block_data |
|||
%nterm <std::string> item_value |
|||
%nterm <std::string> block_name |
|||
%nterm <std::vector<a2l::IfDataItem>> item_list |
|||
|
|||
%start if_data_block |
|||
|
|||
%% |
|||
|
|||
if_data_block: %empty |
|||
| IF_DATA_BEGIN IF_DATA protocol block_data_list IF_DATA_END IF_DATA { |
|||
scanner.Protocol($3); |
|||
scanner.ItemList($4); |
|||
}; |
|||
|
|||
protocol: IDENT; |
|||
|
|||
block_data_list: %empty {} |
|||
| block_data_list block_data { |
|||
$$ = $1; |
|||
$$.emplace_back($2); |
|||
} |
|||
| block_data_list item_value { |
|||
$$ = $1; |
|||
IfDataItem item; |
|||
item.Value = $2; |
|||
$$.emplace_back($2); |
|||
}; |
|||
|
|||
block_data: IF_DATA_BEGIN block_name item_list IF_DATA_END block_name { |
|||
IfDataItem block; |
|||
block.BlockName = $2; |
|||
block.ItemList = $3; |
|||
$$ = block; |
|||
}; |
|||
|
|||
block_name: IDENT { $$ = $1; }; |
|||
|
|||
item_list: %empty {} |
|||
| item_list block_data { |
|||
$$ = $1; |
|||
$$.emplace_back($2); |
|||
} |
|||
| item_list item_value { |
|||
$$ = $1; |
|||
IfDataItem item; |
|||
item.Value = $2; |
|||
$$.emplace_back($2); |
|||
}; |
|||
|
|||
item_value: IDENT { $$ = $1; } |
|||
| STRING { $$ = $1; } |
|||
| HEX { $$ = std::to_string($1); } |
|||
| UINT { $$ = std::to_string($1); } |
|||
| INT { $$ = std::to_string($1); } |
|||
| FLOAT { $$ = std::to_string($1); }; |
|||
|
|||
|
|||
%% |
|||
|
|||
void a2l::IfDataParser::error(const std::string& err) { |
|||
const auto line = scanner.lineno(); |
|||
// const auto column = scanner.YYLeng(); |
|||
const std::string near = scanner.YYText() != nullptr ? scanner.YYText() : ""; |
|||
std::ostringstream error; |
|||
error << "Parser error: " << err |
|||
<< ", Line: " << line |
|||
<< ", Near: " << near; |
|||
scanner.LastError(error.str()); |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "ifdatascanner.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
|
|||
IfDataScanner::IfDataScanner(std::istream& message) |
|||
: ifdataFlexLexer(&message), yylval(nullptr) { |
|||
|
|||
} |
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,55 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <fstream> |
|||
#include <string> |
|||
#include <memory> |
|||
|
|||
#ifndef yyFlexLexerOnce |
|||
|
|||
#undef yyFlexLexer |
|||
#define yyFlexLexer ifdataFlexLexer |
|||
#include <FlexLexer.h> |
|||
|
|||
#endif |
|||
|
|||
#include <map> |
|||
#include <memory> |
|||
#include <sstream> |
|||
#include <vector> |
|||
#include <stack> |
|||
#include "ifdataparser.hpp" |
|||
#include "a2l/ifdataitem.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
class IfDataScanner : public ifdataFlexLexer { |
|||
public: |
|||
explicit IfDataScanner(std::istream& in); |
|||
int ifdatalex(IfDataParser::value_type* yylval); |
|||
|
|||
void LastError(const std::string& error) { last_error_ = error; } |
|||
[[nodiscard]] const std::string& LastError() const { return last_error_; } |
|||
|
|||
void Protocol(const std::string& protocol) { protocol_ = protocol; } |
|||
[[nodiscard]] const std::string& Protocol() const { return protocol_; } |
|||
|
|||
void ItemList(const std::vector<IfDataItem>& list) { item_list_ = list; } |
|||
[[nodiscard]] const std::vector<IfDataItem>& ItemList() const { |
|||
return item_list_; |
|||
} |
|||
private: |
|||
IfDataParser::semantic_type* yylval = nullptr; |
|||
std::string last_error_; |
|||
|
|||
std::string protocol_; |
|||
std::vector<IfDataItem> item_list_; |
|||
|
|||
|
|||
}; |
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,12 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
#include "a2l/instance.h" |
|||
namespace a2l { |
|||
|
|||
void Instance::AddOverwrite(std::unique_ptr<Overwrite>& overwrite) { |
|||
overwrite_list_.emplace_back( std::move(overwrite) ); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
|
|||
|
|||
#include "a2l/measurement.h" |
|||
|
|||
|
|||
namespace a2l { |
|||
|
|||
} |
|||
@ -0,0 +1,159 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/module.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
void Module::AddAxisPts(std::unique_ptr<AxisPts>& axis_pts) { |
|||
axis_pts_list_.emplace(axis_pts->Name(), std::move(axis_pts)); |
|||
} |
|||
|
|||
void Module::AddBlob(std::unique_ptr<Blob>& blob) { |
|||
blob_list_.emplace(blob->Name(), std::move(blob)); |
|||
} |
|||
|
|||
void Module::AddCharacteristic(std::unique_ptr<Characteristic>& |
|||
characteristic) { |
|||
characteristic_list_.emplace(characteristic->Name(), |
|||
std::move(characteristic)); |
|||
} |
|||
|
|||
void Module::AddCompuMethod(std::unique_ptr<CompuMethod>& method) { |
|||
compu_method_list_.emplace(method->Name(), std::move(method)); |
|||
} |
|||
|
|||
void Module::AddCompuTab(std::unique_ptr<CompuTab>& tab) { |
|||
compu_tab_list_.emplace(tab->Name(), std::move(tab)); |
|||
} |
|||
|
|||
void Module::AddCompuVtab(std::unique_ptr<CompuVtab>& tab) { |
|||
compu_vtab_list_.emplace(tab->Name(), std::move(tab)); |
|||
} |
|||
|
|||
void Module::AddCompuVtabRange(std::unique_ptr<CompuVtabRange>& tab) { |
|||
compu_vtab_range_list_.emplace(tab->Name(), std::move(tab)); |
|||
} |
|||
|
|||
void Module::AddFrame(std::unique_ptr<Frame>& frame) { |
|||
frame_list_.emplace(frame->Name(), std::move(frame)); |
|||
} |
|||
|
|||
void Module::AddFunction(std::unique_ptr<Function>& func) { |
|||
function_list_.emplace(func->Name(), std::move(func)); |
|||
} |
|||
|
|||
void Module::AddGroup(std::unique_ptr<Group>& group) { |
|||
group_list_.emplace(group->Name(), std::move(group)); |
|||
} |
|||
|
|||
void Module::AddInstance(std::unique_ptr<Instance>& instance) { |
|||
instance_list_.emplace(instance->Name(), std::move(instance)); |
|||
} |
|||
|
|||
void Module::AddMeasurement(std::unique_ptr<Measurement>& measurement) { |
|||
measurement_list_.emplace(measurement->Name(), std::move(measurement)); |
|||
} |
|||
|
|||
void Module::AddRecordLayout(std::unique_ptr<RecordLayout>& record_layout) { |
|||
record_layout_list_.emplace(record_layout->Name(), std::move(record_layout)); |
|||
} |
|||
|
|||
void Module::AddTransformer(std::unique_ptr<Transformer>& transformer) { |
|||
transformer_list_.emplace(transformer->Name(), std::move(transformer)); |
|||
} |
|||
|
|||
void Module::AddTypedefAxis(std::unique_ptr<AxisPts>& axis) { |
|||
typedef_axis_list_.emplace(axis->Name(), std::move(axis)); |
|||
} |
|||
|
|||
void Module::AddTypedefBlob(std::unique_ptr<Blob>& blob) { |
|||
typedef_blob_list_.emplace(blob->Name(), std::move(blob)); |
|||
} |
|||
|
|||
void Module::AddTypedefCharacteristic(std::unique_ptr<Characteristic>& |
|||
characteristic) { |
|||
typedef_characteristic_list_.emplace(characteristic->Name(), |
|||
std::move(characteristic)); |
|||
} |
|||
|
|||
void Module::AddTypedefMeasurement(std::unique_ptr<Measurement>& measurement){ |
|||
typedef_measurement_list_.emplace(measurement->Name(), |
|||
std::move(measurement)); |
|||
} |
|||
|
|||
void Module::AddTypedefStructure(std::unique_ptr<Structure>& structure){ |
|||
typedef_structure_list_.emplace(structure->Name(), std::move(structure)); |
|||
} |
|||
|
|||
void Module::AddUnit(std::unique_ptr<Unit>& unit){ |
|||
unit_list_.emplace(unit->Name(), std::move(unit)); |
|||
} |
|||
|
|||
void Module::AddUserRight(std::unique_ptr<A2lUserRight>& user_right){ |
|||
user_right_list_.emplace(user_right->UserLevelId, std::move(user_right)); |
|||
} |
|||
|
|||
AxisPts* Module::GetAxisPts(const std::string& name) { |
|||
auto itr = axis_pts_list_.find(name); |
|||
return itr == axis_pts_list_.end() ? nullptr : itr->second.get(); |
|||
} |
|||
|
|||
Blob* Module::GetBlob(const std::string& name) { |
|||
auto itr = blob_list_.find(name); |
|||
return itr == blob_list_.end() ? nullptr : itr->second.get(); |
|||
} |
|||
|
|||
Characteristic* Module::GetCharacteristic(const std::string& name) { |
|||
auto itr = characteristic_list_.find(name); |
|||
return itr == characteristic_list_.end() ? nullptr : itr->second.get(); |
|||
} |
|||
|
|||
CompuTab* Module::GetCompuTab(const std::string& name) { |
|||
auto itr = compu_tab_list_.find(name); |
|||
return itr == compu_tab_list_.end() ? nullptr : itr->second.get(); |
|||
} |
|||
|
|||
CompuVtab* Module::GetCompuVtab(const std::string& name) { |
|||
auto itr = compu_vtab_list_.find(name); |
|||
return itr == compu_vtab_list_.end() ? nullptr : itr->second.get(); |
|||
} |
|||
|
|||
CompuVtabRange* Module::GetCompuVtabRange(const std::string& name) { |
|||
auto itr = compu_vtab_range_list_.find(name); |
|||
return itr == compu_vtab_range_list_.end() ? nullptr : itr->second.get(); |
|||
} |
|||
|
|||
Measurement* Module::GetMeasurement(const std::string& name) { |
|||
auto itr = measurement_list_.find(name); |
|||
return itr == measurement_list_.end() ? nullptr : itr->second.get(); |
|||
} |
|||
|
|||
AxisPts* Module::GetTypedefAxis(const std::string& name) { |
|||
auto itr = typedef_axis_list_.find(name); |
|||
return itr == typedef_axis_list_.end() ? nullptr : itr->second.get(); |
|||
} |
|||
|
|||
Blob* Module::GetTypedefBlob(const std::string& name) { |
|||
auto itr = typedef_blob_list_.find(name); |
|||
return itr == typedef_blob_list_.end() ? nullptr : itr->second.get(); |
|||
} |
|||
|
|||
Characteristic* Module::GetTypedefCharacteristic(const std::string& name) { |
|||
auto itr = typedef_characteristic_list_.find(name); |
|||
return itr == typedef_characteristic_list_.end() ? nullptr : itr->second.get(); |
|||
} |
|||
|
|||
Measurement* Module::GetTypedefMeasurement(const std::string& name) { |
|||
auto itr = typedef_measurement_list_.find(name); |
|||
return itr == typedef_measurement_list_.end() ? nullptr : itr->second.get(); |
|||
} |
|||
|
|||
Structure* Module::GetTypedefStructure(const std::string& name) { |
|||
auto itr = typedef_structure_list_.find(name); |
|||
return itr == typedef_structure_list_.end() ? nullptr : itr->second.get(); |
|||
} |
|||
|
|||
} // namespace a2l
|
|||
@ -0,0 +1,10 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/overwrite.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/recordlayout.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
void RecordLayout::AddReserved(const A2lDistOp& reserved) { |
|||
reserved_list_.emplace_back(reserved); |
|||
} |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,10 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/structure.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
@ -0,0 +1,10 @@ |
|||
/*
|
|||
* Copyright 2023 Ingemar Hedvall |
|||
* SPDX-License-Identifier: MIT |
|||
*/ |
|||
|
|||
#include "a2l/unit.h" |
|||
|
|||
namespace a2l { |
|||
|
|||
} // end namespace a2l
|
|||
@ -0,0 +1,8 @@ |
|||
#pragma once |
|||
|
|||
// SDKDDKVer.h를 포함하면 최고 수준의 가용성을 가진 Windows 플랫폼이 정의됩니다.
|
|||
|
|||
// 이전 Windows 플랫폼에 대해 애플리케이션을 빌드하려는 경우에는 SDKDDKVer.h를 포함하기 전에
|
|||
// WinSDKVer.h를 포함하고 _WIN32_WINNT 매크로를 지원하려는 플랫폼으로 설정하십시오.
|
|||
|
|||
#include <SDKDDKVer.h> |
|||
Loading…
Reference in new issue