Static Public Member Functions | Private Member Functions | Static Private Member Functions | List of all members
swarmio::data::Helper Class Referencefinal

This Helper class contains commonly used function to manipulate protobuf objects. More...

#include <Helper.h>

Static Public Member Functions

static Variant::ValueCase GetBaseType (const Variant &value)
 Get the base type of the variant array, or its type if it is not an array. More...
 
static size_t GetCount (const Variant &value)
 Get the item count of the variant array, or 1 if it is not an array. More...
 
static discovery::Field GetFieldDescriptor (const Variant &value, bool includeArraySizes=false)
 Get the schema for an existing map. More...
 
static discovery::Schema GetSchemaDescriptor (const Map &value, bool includeArraySizes=false)
 Get the schema for an existing map. More...
 
static bool IsArray (const Variant &value)
 Check whether the variant contains an array type. More...
 
static std::string ToString (const discovery::Schema &value, bool prettyPrint=true)
 Get a string representation of a schema. More...
 
static std::string ToString (const Variant &value, bool prettyPrint=true)
 Get a string representation of a variant. More...
 
static std::string ToString (const Map &value, bool prettyPrint=true)
 Get a string representation of a map. More...
 
static std::string ToString (const google::protobuf::Map< std::string, swarmio::data::Variant > &value, bool prettyPrint=true)
 Get a string representation of a map. More...
 
static void WriteToStream (std::ostream &stream, const Variant &value, bool prettyPrint=true, int indentationLevel=0)
 Write a string representation of a variant to the stream. More...
 
static void WriteToStream (std::ostream &stream, const Map &value, bool prettyPrint=true, int indentationLevel=0)
 Write a string representation of a map to the stream. More...
 
static void WriteToStream (std::ostream &stream, const google::protobuf::Map< std::string, swarmio::data::Variant > &value, bool prettyPrint=true, int indentationLevel=0)
 Write a string representation of a map to the stream. More...
 
static void WriteToStream (std::ostream &stream, const discovery::Schema &value, bool prettyPrint=true, int indentationLevel=0)
 Write a string representation of a schema to the stream. More...
 

Private Member Functions

 Helper ()
 Disable construction. More...
 

Static Private Member Functions

static const char * TypeToString (discovery::Type type)
 Look up the human readable name of a type. More...
 
static void WriteElementSeparatorToStream (std::ostream &stream, bool &first, bool prettyPrint, int indentationLevel)
 Write the element separator between two elements of an array. More...
 
static void WriteEscapedAndQuotedStringToStream (std::ostream &stream, const std::string &value)
 Write an escaped and quoted string to the stream. More...
 

Detailed Description

This Helper class contains commonly used function to manipulate protobuf objects.

Definition at line 15 of file Helper.h.

Constructor & Destructor Documentation

swarmio::data::Helper::Helper ( )
inlineprivate

Disable construction.

Definition at line 23 of file Helper.h.

Member Function Documentation

data::Variant::ValueCase Helper::GetBaseType ( const Variant &  value)
static

Get the base type of the variant array, or its type if it is not an array.

Parameters
valueVariant
Returns
Variant::ValueCase

Definition at line 53 of file Helper.cpp.

size_t Helper::GetCount ( const Variant &  value)
static

Get the item count of the variant array, or 1 if it is not an array.

Parameters
valueVariant
Returns
size_t

Definition at line 26 of file Helper.cpp.

discovery::Field Helper::GetFieldDescriptor ( const Variant &  value,
bool  includeArraySizes = false 
)
static

Get the schema for an existing map.

Parameters
valueValue
includeArraySizesMark arrays as fixed size
Returns
discovery::Field

Definition at line 91 of file Helper.cpp.

discovery::Schema Helper::GetSchemaDescriptor ( const Map &  value,
bool  includeArraySizes = false 
)
static

Get the schema for an existing map.

Parameters
valueValue
includeArraySizesMark arrays as fixed size
Returns
discovery::Schema

Definition at line 80 of file Helper.cpp.

bool Helper::IsArray ( const Variant &  value)
static

Check whether the variant contains an array type.

Parameters
valueVariant
Returns
True if the variant is an array

Definition at line 10 of file Helper.cpp.

std::string Helper::ToString ( const discovery::Schema &  value,
bool  prettyPrint = true 
)
static

Get a string representation of a schema.

Parameters
valueSchema
prettyPrintAdd indentation and spacing
Returns
std::string

Definition at line 154 of file Helper.cpp.

std::string Helper::ToString ( const Variant &  value,
bool  prettyPrint = true 
)
static

Get a string representation of a variant.

Parameters
valueVariant
prettyPrintAdd indentation and spacing
Returns
std::string

Definition at line 161 of file Helper.cpp.

std::string Helper::ToString ( const Map &  value,
bool  prettyPrint = true 
)
static

Get a string representation of a map.

Parameters
valueMap
prettyPrintAdd indentation and spacing
Returns
std::string

Definition at line 168 of file Helper.cpp.

std::string Helper::ToString ( const google::protobuf::Map< std::string, swarmio::data::Variant > &  value,
bool  prettyPrint = true 
)
static

Get a string representation of a map.

Parameters
valueMap
prettyPrintAdd indentation and spacing
Returns
std::string

Definition at line 175 of file Helper.cpp.

const char * Helper::TypeToString ( discovery::Type  type)
staticprivate

Look up the human readable name of a type.

Parameters
typeType
Returns
const char*

Definition at line 432 of file Helper.cpp.

void Helper::WriteElementSeparatorToStream ( std::ostream &  stream,
bool &  first,
bool  prettyPrint,
int  indentationLevel 
)
staticprivate

Write the element separator between two elements of an array.

Parameters
streamStream
firstFirst element marker
prettyPrintAdd indentation and spacing
indentationLevelCurrent indentation level

Definition at line 232 of file Helper.cpp.

void Helper::WriteEscapedAndQuotedStringToStream ( std::ostream &  stream,
const std::string &  value 
)
staticprivate

Write an escaped and quoted string to the stream.

Parameters
streamStream
valueString

Definition at line 182 of file Helper.cpp.

void Helper::WriteToStream ( std::ostream &  stream,
const Variant &  value,
bool  prettyPrint = true,
int  indentationLevel = 0 
)
static

Write a string representation of a variant to the stream.

Parameters
streamStream
prettyPrintAdd indentation and spacing
indentationLevelCurrent indentation level
valueVariant

Definition at line 255 of file Helper.cpp.

void Helper::WriteToStream ( std::ostream &  stream,
const Map &  value,
bool  prettyPrint = true,
int  indentationLevel = 0 
)
static

Write a string representation of a map to the stream.

Parameters
streamStream
prettyPrintAdd indentation and spacing
indentationLevelCurrent indentation level
valueMap

Definition at line 370 of file Helper.cpp.

void Helper::WriteToStream ( std::ostream &  stream,
const google::protobuf::Map< std::string, swarmio::data::Variant > &  value,
bool  prettyPrint = true,
int  indentationLevel = 0 
)
static

Write a string representation of a map to the stream.

Parameters
streamStream
prettyPrintAdd indentation and spacing
indentationLevelCurrent indentation level
valueMap

Definition at line 375 of file Helper.cpp.

void Helper::WriteToStream ( std::ostream &  stream,
const discovery::Schema &  value,
bool  prettyPrint = true,
int  indentationLevel = 0 
)
static

Write a string representation of a schema to the stream.

Parameters
streamStream
prettyPrintAdd indentation and spacing
indentationLevelCurrent indentation level
valueSchema

Definition at line 456 of file Helper.cpp.


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


swarmros
Author(s):
autogenerated on Fri Apr 3 2020 03:42:48