initial commit for github

This commit is contained in:
Pierre 2019-12-12 14:41:47 +01:00
commit 60968612de
370 changed files with 68427 additions and 0 deletions

View file

@ -0,0 +1,30 @@
set(PROJECT_NAME ddl2header)
set(SOURCES
main.cpp
ddl2header_commandline.h
ddl2header_commandline.cpp
${DDL_GENERATOR_COMMON}
${HEADER_PRESENTATION_H}
${HEADER_PRESENTATION_CPP}
)
if (WIN32)
#list(APPEND SOURCES native_resource.rc)
endif (WIN32)
add_executable(${PROJECT_NAME} WIN32 ${SOURCES})
target_link_libraries(${PROJECT_NAME}
ddl
ddl_generator
)
if(MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/SUBSYSTEM:console")
endif(MSVC)
install(TARGETS ${PROJECT_NAME} DESTINATION ./bin/debug CONFIGURATIONS Debug)
install(TARGETS ${PROJECT_NAME} DESTINATION ./bin CONFIGURATIONS Release RelWithDebInfo)
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER ddl/utils)

View file

@ -0,0 +1,79 @@
/**
* @file
* @copyright
* @verbatim
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
This Source Code Form is subject to the terms of the Mozilla
Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular file, then
You may include the notice in a location (such as a LICENSE file in a
relevant directory) where a recipient would be likely to look for such a notice.
You may add additional accurate notices of copyright ownership.
@endverbatim
*/
#include <iostream>
#include "ddl2header_commandline.h"
namespace ddl_generator
{
namespace oo
{
//define all needed error types and values locally
_MAKE_RESULT(0, ERR_NOERROR)
_MAKE_RESULT(-5, ERR_INVALID_ARG)
}
}
using namespace ddl_generator::oo;
namespace ddl
{
DDL2HeaderCommandLine::DDL2HeaderCommandLine(): CommandLine()
{
_cli |= getNamespaceOpt();
_cli |= getDisplaceableStringOpt();
}
std::string DDL2HeaderCommandLine::getNamespace()
{
return _opt_namespace;
}
std::string DDL2HeaderCommandLine::getDisplaceableString()
{
return _opt_displaceable_string;
}
void DDL2HeaderCommandLine::printExamples()
{
std::cout << std::endl << "If the target header file exists already the descriptions will be merged." << std::endl;
std::cout << "This can lead to data loss in the existing header file." << std::endl << std::endl;
std::cout << "examples: " << std::endl;
std::cout << " --headerfile=c:/myHeaderFile.h " <<
"--descriptionfile=c:/myDescriptionFile.description";
std::cout << std::endl << " or" << std::endl;
std::cout << " --headerfile=c:/myHeaderFile.h " <<
"--descriptionfile=c:/myDescriptionFile.description ";
std::cout << "-struct=tMyStruct" << std::endl;
}
clara::Opt DDL2HeaderCommandLine::getNamespaceOpt()
{
return clara::Opt(_opt_namespace, "name")
["-n"]["--namespace"]
("[Optional] Place all generated elements in this namespace");
}
clara::Opt DDL2HeaderCommandLine::getDisplaceableStringOpt()
{
return clara::Opt(_opt_displaceable_string, "string")
["--displace"]
(" [Optional] Remove this string from beginning of all element names.");
}
}

View file

@ -0,0 +1,47 @@
/**
* @file
* @copyright
* @verbatim
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
This Source Code Form is subject to the terms of the Mozilla
Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular file, then
You may include the notice in a location (such as a LICENSE file in a
relevant directory) where a recipient would be likely to look for such a notice.
You may add additional accurate notices of copyright ownership.
@endverbatim
*/
#ifndef _DDL2HEADER_COMMAND_LINE_H_
#define _DDL2HEADER_COMMAND_LINE_H_
#include "commandline.h"
namespace ddl
{
class DDL2HeaderCommandLine: public ddl::CommandLine
{
public:
DDL2HeaderCommandLine();
std::string getNamespace();
std::string getDisplaceableString();
protected:
void printExamples();
clara::Opt getNamespaceOpt();
clara::Opt getDisplaceableStringOpt();
std::string _opt_namespace;
std::string _opt_displaceable_string;
};
}
#endif

View file

@ -0,0 +1,66 @@
/**
* @file
* Launcher.
*
* @copyright
* @verbatim
Copyright @ 2017 Audi Electronics Venture GmbH. All rights reserved.
This Source Code Form is subject to the terms of the Mozilla
Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular file, then
You may include the notice in a location (such as a LICENSE file in a
relevant directory) where a recipient would be likely to look for such a notice.
You may add additional accurate notices of copyright ownership.
@endverbatim
*/
#include <a_util/result.h>
#include <ddl_generator_core.h>
#include "ddl2header_commandline.h"
namespace ddl_generator
{
namespace oo
{
//define all needed error types and values locally
_MAKE_RESULT(0, ERR_NOERROR)
_MAKE_RESULT(-5, ERR_INVALID_ARG)
}
}
using namespace ddl_generator::oo;
int main(int argc, char* argv[])
{
ddl::DDL2HeaderCommandLine cmdLine;
if (a_util::result::isFailed(cmdLine.parseArgs(argc, argv)))
{
return ERR_INVALID_ARG.getCode();
}
if (cmdLine.isHelpRequested())
{
cmdLine.printHelp();
return ERR_NOERROR.getCode();
}
if (a_util::result::isFailed(cmdLine.checkMandatoryArguments()))
{
return ERR_INVALID_ARG.getCode();
}
DDLUtilsCore core;
a_util::result::Result res = core.generateHeaderFile(cmdLine.getDescriptionFile(),
cmdLine.getHeaderFile(), cmdLine.getStruct(), cmdLine.getNamespace(),
cmdLine.getDisplaceableString());
if (a_util::result::isFailed(res))
{
LOG_ERROR("Error: An error occured during generating the header file.");
}
return res.getErrorCode();
}