13 std::unordered_map<std::string, std::string> &allowedMap,
14 std::unordered_map<std::string, std::string> &outArgs)
16 const std::set<std::string> booleanArgs{
"verbose",
"help"};
17 std::set<std::string> allowedKeys;
18 std::set<std::string> allowedShortKeys;
19 for (
const auto& [k, v] : allowedMap) {
20 allowedShortKeys.insert(k);
21 allowedKeys.insert(v);
23 for (
int i = 1; i < argc; ++i) {
24 std::string current = argv[i];
27 if (current.rfind(
"--", 0) == 0 || current.rfind(
'-', 0) == 0) {
29 if (current.rfind(
"--", 0) == 0){
30 key = current.substr(2);
32 std::string sKey = current.substr(1);
34 key = allowedMap.at(sKey);
38 if (booleanArgs.find(key) != booleanArgs.end()) {
39 outArgs[key] =
"true";
42 const std::string value = argv[++i];
52void customConsole(
const std::string& appName,
const std::string& message,
const std::string& logLevel ) {
54 const auto now = std::chrono::high_resolution_clock::now();
55 const auto duration = now.time_since_epoch();
56 const auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>(duration);
59 const std::time_t currentTime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
60 const std::tm* tm = std::localtime(¤tTime);
63 std::ostringstream timestampStream;
64 timestampStream << std::put_time(tm,
"%Y-%m-%d %H:%M:%S");
67 std::cout <<
"[" << timestampStream.str() <<
"."
68 << std::setw(6) << std::setfill(
'0') << microseconds.count() % 1000000
69 <<
"] [" << appName <<
"] "
70 <<
"[" << logLevel <<
"] : "
71 << message << std::endl;
CCSDS::ResultBool parseArguments(const int argc, char *argv[], std::unordered_map< std::string, std::string > &allowedMap, std::unordered_map< std::string, std::string > &outArgs)
This is the source file that holds the execution logic of ccsds_encoder binary file.