2023-08-28 12:31:18 +02:00
|
|
|
/* UUID helpers.
|
2021-09-19 19:05:53 +02:00
|
|
|
*
|
2023-08-31 17:35:12 +02:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
2023-08-31 11:17:07 +02:00
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2023-08-28 12:31:18 +02:00
|
|
|
*/
|
2021-09-19 19:05:53 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <jansson.h>
|
|
|
|
#include <uuid/uuid.h>
|
|
|
|
|
2023-06-30 13:01:54 +02:00
|
|
|
typedef char uuid_string_t[37];
|
|
|
|
|
2021-09-19 19:05:53 +02:00
|
|
|
namespace villas {
|
|
|
|
namespace uuid {
|
|
|
|
|
2023-06-30 13:01:54 +02:00
|
|
|
// Convert a UUID to C++ string
|
2023-06-30 13:25:32 +02:00
|
|
|
std::string toString(const uuid_t in);
|
2023-06-30 13:01:54 +02:00
|
|
|
|
2023-04-03 10:00:02 +00:00
|
|
|
// Generate an UUID by MD5 hashing the provided string
|
2023-09-07 13:19:19 +02:00
|
|
|
int generateFromString(uuid_t out, const std::string &data,
|
|
|
|
const std::string &ns = "");
|
2021-09-19 19:05:53 +02:00
|
|
|
|
2023-04-03 10:00:02 +00:00
|
|
|
// Generate an UUID by MD5 hashing the provided string
|
2021-09-19 19:05:53 +02:00
|
|
|
int generateFromString(uuid_t out, const std::string &data, const uuid_t ns);
|
|
|
|
|
2023-04-03 10:00:02 +00:00
|
|
|
// Generate an UUID by MD5 hashing the serialized representation of the provided JSON object
|
2021-09-19 19:05:53 +02:00
|
|
|
void generateFromJson(uuid_t out, json_t *json, const std::string &ns = "");
|
|
|
|
|
2023-04-03 10:00:02 +00:00
|
|
|
// Generate an UUID by MD5 hashing the serialized representation of the provided JSON object
|
2021-09-19 19:05:53 +02:00
|
|
|
int generateFromJson(uuid_t out, json_t *json, const uuid_t ns);
|
|
|
|
|
2022-12-02 17:16:44 +01:00
|
|
|
} // namespace uuid
|
|
|
|
} // namespace villas
|