-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
30 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Steinwurf ApS 2020. | ||
// All Rights Reserved | ||
// | ||
// Distributed under the "BSD License". See the accompanying LICENSE.rst file. | ||
|
||
#include "parse_metadata.hpp" | ||
|
||
#include <cassert> | ||
#include <optional> | ||
|
||
namespace abacus | ||
{ | ||
inline namespace STEINWURF_ABACUS_VERSION | ||
{ | ||
auto parse_metadata(const uint8_t* metadata_data, std::size_t metadata_bytes) | ||
-> std::optional<protobuf::MetricsMetadata> | ||
{ | ||
assert(metadata_data != nullptr); | ||
assert(metadata_bytes > 0); | ||
protobuf::MetricsMetadata metadata; | ||
auto result = metadata.ParseFromArray(metadata_data, metadata_bytes); | ||
if (!result) | ||
{ | ||
return std::nullopt; | ||
} | ||
return metadata; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Steinwurf ApS 2020. | ||
// All Rights Reserved | ||
// | ||
// Distributed under the "BSD License". See the accompanying LICENSE.rst file. | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
#include "protobuf/metrics.pb.h" | ||
#include "version.hpp" | ||
|
||
namespace abacus | ||
{ | ||
inline namespace STEINWURF_ABACUS_VERSION | ||
{ | ||
|
||
/// @param metadata_data The meta data pointer | ||
/// @param metadata_bytes The meta data size in bytes | ||
auto parse_metadata(const uint8_t* metadata_data, std::size_t metadata_bytes) | ||
-> std::optional<protobuf::MetricsMetadata>; | ||
|
||
} | ||
} |