Helper.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <swarmio/data/Variant.pb.h>
4 #include <swarmio/data/discovery/Schema.pb.h>
5 #include <sstream>
6 
7 namespace swarmio::data
8 {
15  class SWARMIO_API Helper final
16  {
17  private:
18 
23  Helper() { }
24 
31  static const char* TypeToString(discovery::Type type);
32 
39  static void WriteEscapedAndQuotedStringToStream(std::ostream& stream, const std::string& value);
40 
49  static void WriteElementSeparatorToStream(std::ostream& stream, bool& first, bool prettyPrint, int indentationLevel);
50 
51  public:
52 
59  static bool IsArray(const Variant& value);
60 
68  static size_t GetCount(const Variant& value);
69 
77  static Variant::ValueCase GetBaseType(const Variant& value);
78 
86  static discovery::Schema GetSchemaDescriptor(const Map& value, bool includeArraySizes = false);
87 
95  static discovery::Field GetFieldDescriptor(const Variant& value, bool includeArraySizes = false);
96 
104  static std::string ToString(const discovery::Schema& value, bool prettyPrint = true);
105 
113  static std::string ToString(const Variant& value, bool prettyPrint = true);
114 
122  static std::string ToString(const Map& value, bool prettyPrint = true);
123 
131  static std::string ToString(const google::protobuf::Map<std::string, swarmio::data::Variant>& value, bool prettyPrint = true);
132 
141  static void WriteToStream(std::ostream& stream, const Variant& value, bool prettyPrint = true, int indentationLevel = 0);
142 
151  static void WriteToStream(std::ostream& stream, const Map& value, bool prettyPrint = true, int indentationLevel = 0);
152 
161  static void WriteToStream(std::ostream& stream, const google::protobuf::Map<std::string, swarmio::data::Variant>& value, bool prettyPrint = true, int indentationLevel = 0);
162 
171  static void WriteToStream(std::ostream& stream, const discovery::Schema& value, bool prettyPrint = true, int indentationLevel = 0);
172  };
173 }
Helper()
Disable construction.
Definition: Helper.h:23
This Helper class contains commonly used function to manipulate protobuf objects. ...
Definition: Helper.h:15


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