src/primitives/version.hpp¶
Namespaces¶
| Name |
|---|
| sgns |
| sgns::primitives |
Classes¶
| Name | |
|---|---|
| struct | sgns::primitives::Version |
Types¶
| Name | |
|---|---|
| using base::Blob< 8u > | ApiId The identity of a particular API interface that the runtime might provide. |
| using std::pair< ApiId, uint32_t > | Api single Api item |
| using std::vector< Api > | ApisVec A vector of pairs of ApiId and a u32 for version. |
Functions¶
| Name | |
|---|---|
| template <class Stream ,typename =std::enable_if_t Stream & |
operator<<(Stream & s, const Version & v) outputs object of type Version to stream |
| template <class Stream ,typename =std::enable_if_t Stream & |
operator>>(Stream & s, Version & v) decodes object of type Version from stream |
Types Documentation¶
using ApiId¶
The identity of a particular API interface that the runtime might provide.
This is the same structure as RuntimeVersion from substrate
using Api¶
single Api item
using ApisVec¶
A vector of pairs of ApiId and a u32 for version.
Functions Documentation¶
function operator<<¶
template <class Stream ,
typename =std::enable_if_t<Stream::is_encoder_stream>>
Stream & operator<<(
Stream & s,
const Version & v
)
outputs object of type Version to stream
Parameters:
- s stream reference
- v value to output
Template Parameters:
- Stream output stream type
Return: reference to stream
function operator>>¶
template <class Stream ,
typename =std::enable_if_t<Stream::is_decoder_stream>>
Stream & operator>>(
Stream & s,
Version & v
)
decodes object of type Version from stream
Parameters:
- s stream reference
- v value to decode
Template Parameters:
- Stream input stream type
Return: reference to stream
Source code¶
#ifndef SUPERGENIUS_SRC_PRIMITIVES_VERSION_HPP
#define SUPERGENIUS_SRC_PRIMITIVES_VERSION_HPP
#include <string>
#include <vector>
#include "base/blob.hpp"
namespace sgns::primitives {
using ApiId = base::Blob<8u>;
using Api = std::pair<ApiId, uint32_t>;
using ApisVec = std::vector<Api>;
struct Version {
std::string spec_name;
std::string impl_name;
uint32_t authoring_version = 0u;
uint32_t spec_version = 0u;
uint32_t impl_version = 0u;
ApisVec apis;
bool operator==(const Version &rhs) const {
return spec_name == rhs.spec_name && impl_name == rhs.impl_name
&& authoring_version == rhs.authoring_version
&& impl_version == rhs.impl_version && apis == rhs.apis
&& spec_version == rhs.spec_version;
}
bool operator!=(const Version &rhs) const {
return !operator==(rhs);
}
//added to fix link error in test mode
friend std::ostream &operator<<(std::ostream &out, const Version &v)
{
return out << v.spec_name << v.impl_name << v.authoring_version
<< v.spec_version << v.impl_version << v.apis.size();
}
//end
};
template <class Stream,
typename = std::enable_if_t<Stream::is_encoder_stream>>
Stream &operator<<(Stream &s, const Version &v) {
return s << v.spec_name << v.impl_name << v.authoring_version
<< v.spec_version << v.impl_version << v.apis;
}
template <class Stream,
typename = std::enable_if_t<Stream::is_decoder_stream>>
Stream &operator>>(Stream &s, Version &v) {
return s >> v.spec_name >> v.impl_name >> v.authoring_version
>> v.spec_version >> v.impl_version >> v.apis;
}
} // namespace sgns::primitives
#endif // SUPERGENIUS_SRC_PRIMITIVES_VERSION_HPP
Updated on 2026-03-04 at 13:10:44 -0800