mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-04-20 11:18:16 +00:00
Update sdv_packager (#6)
This commit is contained in:
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#include "cmdlnparser.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -537,11 +550,33 @@ void CCommandLine::DumpArguments(std::ostream& rstream, bool bAll /*= true*/) co
|
||||
|
||||
std::vector<std::string> CCommandLine::IncompatibleArguments(size_t nArgumentGroup, bool bFull /*= true*/) const
|
||||
{
|
||||
std::vector<std::string> vecIncompatible;
|
||||
// Create a copy of the list and remove all arguments that are available and fit.
|
||||
auto lstSuppliedCopy = m_lstSupplied;
|
||||
for (auto& prArgument : m_lstSupplied)
|
||||
{
|
||||
// Only valid for options, not for default arguments
|
||||
if (prArgument.first.get().CheckFlag(EArgumentFlags::default_argument)) continue;
|
||||
if (prArgument.first.get().CheckFlag(EArgumentFlags::default_argument) ||
|
||||
prArgument.first.get().PartOfArgumentGroup(nArgumentGroup))
|
||||
{
|
||||
// Remove the arguments from the supplied copy list
|
||||
auto itArgumentCopy = lstSuppliedCopy.begin();
|
||||
while (itArgumentCopy != lstSuppliedCopy.end())
|
||||
{
|
||||
if (itArgumentCopy->second == prArgument.second)
|
||||
itArgumentCopy = lstSuppliedCopy.erase(itArgumentCopy);
|
||||
else
|
||||
++itArgumentCopy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Left over are the arguments that do not fit.
|
||||
std::vector<std::string> vecIncompatible;
|
||||
for (auto& prArgument : lstSuppliedCopy)
|
||||
{
|
||||
// Only valid for options, not for default arguments
|
||||
if (prArgument.first.get().CheckFlag(EArgumentFlags::default_argument))
|
||||
continue;
|
||||
|
||||
// Is the argument compatible?
|
||||
if (prArgument.first.get().PartOfArgumentGroup(nArgumentGroup)) continue;
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
/********************************************************************************
|
||||
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* Erik Verhoeven - initial API and implementation
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef CMDLN_PARSER_H
|
||||
#define CMDLN_PARSER_H
|
||||
|
||||
@@ -428,8 +441,8 @@ private:
|
||||
uint32_t m_uiParseFlags = 0; ///< The parse flags supplied to the parse function.
|
||||
std::shared_ptr<CArgumentDefBase> m_ptrDefaultArg; ///< Default argument (if available).
|
||||
std::list<std::shared_ptr<CArgumentDefBase>> m_lstOptionArgs; ///< List of configured option arguments (in order of definition).
|
||||
std::map<std::string, CArgumentDefBase&, std::greater<std::string>> m_mapSortedOptions; ///< Map with sorted options.
|
||||
std::map<std::string, CArgumentDefBase&, std::greater<std::string>> m_mapSortedSubOptions; ///< Map with sorted sub-options.
|
||||
std::multimap<std::string, CArgumentDefBase&, std::greater<std::string>> m_mapSortedOptions; ///< Map with sorted options.
|
||||
std::multimap<std::string, CArgumentDefBase&, std::greater<std::string>> m_mapSortedSubOptions; ///< Map with sorted sub-options.
|
||||
std::shared_ptr<SGroupDef> m_ptrCurrentGroup; ///< Current group to assign the options to.
|
||||
std::list<std::pair<std::reference_wrapper<CArgumentDefBase>, std::string>> m_lstSupplied; ///< List of supplied arguments.
|
||||
size_t m_nFixedWidth = 0; ///< Fixed with limit (or 0 for dynamic width).
|
||||
@@ -2677,21 +2690,21 @@ inline void CCommandLine::Parse(size_t nArgs, const TCharType** rgszArgs)
|
||||
};
|
||||
|
||||
// Find the argument
|
||||
// NOTE: Multiple arguments with the same name, but different processing can be defined (based on the argument groups they
|
||||
// might or might not have relevance). Therefore, process all and do not stop after on argument.
|
||||
bool bFound = false;
|
||||
if (bOption)
|
||||
{
|
||||
for (auto& rvtOption : m_mapSortedOptions)
|
||||
{
|
||||
bFound = fnFindAndAssign(rvtOption.second, rvtOption.first);
|
||||
if (bFound) break;
|
||||
bFound |= fnFindAndAssign(rvtOption.second, rvtOption.first);
|
||||
}
|
||||
}
|
||||
else if (bSubOption)
|
||||
{
|
||||
for (auto& rvtOption : m_mapSortedSubOptions)
|
||||
{
|
||||
bFound = fnFindAndAssign(rvtOption.second, rvtOption.first);
|
||||
if (bFound) break;
|
||||
bFound |= fnFindAndAssign(rvtOption.second, rvtOption.first);
|
||||
}
|
||||
} else // Default argument
|
||||
bFound = m_ptrDefaultArg ? fnFindAndAssign(*m_ptrDefaultArg.get(), {}) : false;
|
||||
|
||||
Reference in New Issue
Block a user