2023-09-08 11:35:18 +02:00
|
|
|
/* Vendor, Library, Name, Version (VLNV) tag
|
2017-12-05 17:49:27 +01:00
|
|
|
*
|
2023-01-07 17:20:15 +01:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
2023-09-08 11:35:18 +02:00
|
|
|
* SPDX-FileCopyrightText: 2017 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2023-01-07 17:20:15 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2023-09-08 11:35:18 +02:00
|
|
|
*/
|
2017-12-05 17:49:27 +01:00
|
|
|
|
|
|
|
#include <sstream>
|
2024-02-29 19:34:27 +01:00
|
|
|
#include <string>
|
2017-12-05 17:49:27 +01:00
|
|
|
|
2018-06-04 12:17:23 +02:00
|
|
|
#include <villas/fpga/vlnv.hpp>
|
2017-12-05 17:49:27 +01:00
|
|
|
|
2020-06-14 22:11:15 +02:00
|
|
|
using namespace villas::fpga;
|
2017-12-05 17:49:27 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
bool Vlnv::operator==(const Vlnv &other) const {
|
|
|
|
// If a field is empty, it means wildcard matching everything
|
|
|
|
const bool vendorWildcard = vendor.empty() or other.vendor.empty();
|
|
|
|
const bool libraryWildcard = library.empty() or other.library.empty();
|
|
|
|
const bool nameWildcard = name.empty() or other.name.empty();
|
|
|
|
const bool versionWildcard = version.empty() or other.version.empty();
|
|
|
|
|
|
|
|
const bool vendorMatch = vendorWildcard or vendor == other.vendor;
|
|
|
|
const bool libraryMatch = libraryWildcard or library == other.library;
|
|
|
|
const bool nameMatch = nameWildcard or name == other.name;
|
|
|
|
const bool versionMatch = versionWildcard or version == other.version;
|
|
|
|
|
|
|
|
return vendorMatch and libraryMatch and nameMatch and versionMatch;
|
2017-12-05 17:49:27 +01:00
|
|
|
}
|
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
void Vlnv::parseFromString(std::string vlnv) {
|
|
|
|
// Tokenize by delimiter
|
|
|
|
std::stringstream sstream(vlnv);
|
|
|
|
std::getline(sstream, vendor, delimiter);
|
|
|
|
std::getline(sstream, library, delimiter);
|
|
|
|
std::getline(sstream, name, delimiter);
|
|
|
|
std::getline(sstream, version, delimiter);
|
|
|
|
|
|
|
|
// Represent wildcard internally as empty string
|
|
|
|
if (vendor == "*")
|
|
|
|
vendor = "";
|
|
|
|
if (library == "*")
|
|
|
|
library = "";
|
|
|
|
if (name == "*")
|
|
|
|
name = "";
|
|
|
|
if (version == "*")
|
|
|
|
version = "";
|
2017-12-05 17:49:27 +01:00
|
|
|
}
|
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
std::string Vlnv::toString() const {
|
|
|
|
std::stringstream stream;
|
|
|
|
std::string string;
|
2018-02-13 17:42:01 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
stream << *this;
|
|
|
|
stream >> string;
|
2018-02-13 17:42:01 +01:00
|
|
|
|
2024-02-29 19:34:27 +01:00
|
|
|
return string;
|
2018-02-13 17:42:01 +01:00
|
|
|
}
|