network-experiment/bmrshared/lib/to_tuple.cpp

51 lines
1.6 KiB
C++

// GNU Lesser General Public License v3.0
// Copyright (c) 2023 Bart Beumer <bart@4beumer.nl>
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License v3.0 as published by
// the Free Software Foundation.
//
#include "bmrshared/to_tuple.hpp"
#include <sstream>
#include <string>
#include <vector>
namespace bmrshared
{
std::vector<std::string> detail::GetKeysMissing(const std::vector<std::string>& allKeys,
const std::string* const dataBegin,
std::size_t arraySize)
{
const std::string* const dataEnd = (dataBegin + arraySize);
std::vector<std::string> keysMissing;
for (const std::string* iter = dataBegin; iter != dataEnd; ++iter)
{
auto iterFound = std::find(allKeys.begin(), allKeys.end(), *iter);
if (iterFound == allKeys.end())
{
keysMissing.push_back(*iter);
}
}
return keysMissing;
}
std::vector<std::string> detail::GetKeysNotUsed(const std::vector<std::string>& allKeys,
const std::string* const dataBegin,
std::size_t arraySize)
{
const std::string* const dataEnd = (dataBegin + arraySize);
std::vector<std::string> keysNotUsed;
for (const auto& key : allKeys)
{
auto iterFound = std::find(dataBegin, dataEnd, key);
if (iterFound == dataEnd)
{
keysNotUsed.push_back(key);
}
}
return keysNotUsed;
}
} // namespace bmrshared