MessageSchema Class Reference

Space-ng SDK: sol3::core::MessageSchema Class Reference
Space-ng SDK
sol3::core::MessageSchema Class Reference

#include <sol3/core/message_schema.h>

Public Types

enum class  EvolutionPolicy { ALWAYS , FORWARDS_COMPATIBLE }
 How should this schema evolve. More...
 

Public Member Functions

 MessageSchema ()=default
 
 MessageSchema (flatbuffers::span< uint8_t const > schema_buffer, EvolutionPolicy policy)
 
flatbuffers::span< uint8_t const > schemaBufferSpan () const
 
reflection::Schema const * table () const
 
bool verify (flatbuffers::span< uint8_t const > buffer) const
 
 operator bool () const
 
flatbuffers::Parser const & parser (JsonFormat format=JsonFormat::SINGLE_LINE) const
 
std::string toJson (flatbuffers::span< uint8_t const > buffer, JsonFormat format=JsonFormat::SINGLE_LINE) const
 Convert a verified buffer to JSON using this schema. More...
 
bool operator== (MessageSchema const &schema) const
 Tests if the schema is byte for byte equivalent to the current schema. More...
 
bool operator!= (MessageSchema const &schema) const
 
std::string conformsTo (MessageSchema const &previous_schema) const
 
void evolve (MessageSchema const &new_schema)
 
EvolutionPolicy policy () const
 
std::string fileIdentifierString () const
 Returns the flatbuffer file identifier string, or empty if not set. More...
 
uint32_t fileIdentifier () const
 Returns the flatbuffer file identifier, or 0 if not set. More...
 

Member Enumeration Documentation

◆ EvolutionPolicy

How should this schema evolve.

Enumerator
ALWAYS 

This schema should always be updated, useful for dynamic runtime introspection where we want to be able to parse and introspect every field on the wire

FORWARDS_COMPATIBLE 

This schema should only be used for reading flatbuffers which are forwards compatible. Useful if using compile time types to access message fields.

Constructor & Destructor Documentation

◆ MessageSchema() [1/2]

sol3::core::MessageSchema::MessageSchema ( )
default

◆ MessageSchema() [2/2]

sol3::core::MessageSchema::MessageSchema ( flatbuffers::span< uint8_t const >  schema_buffer,
EvolutionPolicy  policy 
)

Member Function Documentation

◆ conformsTo()

std::string sol3::core::MessageSchema::conformsTo ( MessageSchema const &  previous_schema) const

Tests if this schema is a forwards/backwards compatible evolution of the provided previous schema.

See: https://flatbuffers.dev/evolution/

returns non-empty string that describes any compatibility issues

◆ evolve()

void sol3::core::MessageSchema::evolve ( MessageSchema const &  new_schema)

This will "evolve" the current schema object to the new schema object based on the EvolutionPolicy. This will throw an exception if the new_schema does not match the policy.

Note this will not change the underlying policy.

◆ fileIdentifier()

uint32_t sol3::core::MessageSchema::fileIdentifier ( ) const

Returns the flatbuffer file identifier, or 0 if not set.

◆ fileIdentifierString()

std::string sol3::core::MessageSchema::fileIdentifierString ( ) const

Returns the flatbuffer file identifier string, or empty if not set.

◆ operator bool()

sol3::core::MessageSchema::operator bool ( ) const

◆ operator!=()

bool sol3::core::MessageSchema::operator!= ( MessageSchema const &  schema) const
inline

◆ operator==()

bool sol3::core::MessageSchema::operator== ( MessageSchema const &  schema) const

Tests if the schema is byte for byte equivalent to the current schema.

◆ parser()

flatbuffers::Parser const& sol3::core::MessageSchema::parser ( JsonFormat  format = JsonFormat::SINGLE_LINE) const

Returns a parser that can be used to generate json from messages from this schema.

◆ policy()

EvolutionPolicy sol3::core::MessageSchema::policy ( ) const
inline

◆ schemaBufferSpan()

flatbuffers::span<uint8_t const> sol3::core::MessageSchema::schemaBufferSpan ( ) const
inline

◆ table()

reflection::Schema const* sol3::core::MessageSchema::table ( ) const

◆ toJson()

std::string sol3::core::MessageSchema::toJson ( flatbuffers::span< uint8_t const >  buffer,
JsonFormat  format = JsonFormat::SINGLE_LINE 
) const

Convert a verified buffer to JSON using this schema.

◆ verify()

bool sol3::core::MessageSchema::verify ( flatbuffers::span< uint8_t const >  buffer) const

The documentation for this class was generated from the following file: