ConstantField.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include <swarmio/data/Variant.pb.h>
5 #include <string>
6 
8 {
13  class ConstantField : public Field
14  {
15  private:
16 
21  swarmio::data::Variant _value;
22 
27  std::string _rawValue;
28 
34  void ParseBool(const std::string& value);
35 
41  void ParseFloat(const std::string& value);
42 
48  void ParseString(const std::string& value);
49 
55  void ParseSigned(const std::string& value);
56 
62  void ParseUnsigned(const std::string& value);
63 
64  public:
65 
73  ConstantField(const std::string& name, const Serializer& serializer, const std::string& value);
74 
82  virtual void WriteDefinition(std::stringstream& stream, bool forHash) const override;
83 
90  virtual uint32_t GetDefaultLength(const FieldStack& fieldStack) const override;
91 
99  virtual uint32_t CalculateSerializedLength(const swarmio::data::Variant& value, const FieldStack& fieldStack) const override;
100 
108  virtual void Serialize(ros::serialization::OStream& stream, const swarmio::data::Variant& value, const FieldStack& fieldStack) const override;
109 
116  virtual void EmitDefault(ros::serialization::OStream& stream, const FieldStack& fieldStack) const override;
117 
125  virtual swarmio::data::Variant Deserialize(ros::serialization::IStream& stream, const FieldStack& fieldStack) const override;
126  };
127 }
virtual uint32_t GetDefaultLength(const FieldStack &fieldStack) const override
Get the length of the default value.
virtual void Serialize(ros::serialization::OStream &stream, const swarmio::data::Variant &value, const FieldStack &fieldStack) const override
Serialize a variant onto a stream.
virtual void EmitDefault(ros::serialization::OStream &stream, const FieldStack &fieldStack) const override
Write the default value to the stream.
void ParseSigned(const std::string &value)
Parse a signed integer value.
A Field represents an entry in a message reader that can read one of its fields.
Definition: Field.h:15
void ParseFloat(const std::string &value)
Parse a floating point value.
void ParseString(const std::string &value)
Parse a string value.
void ParseBool(const std::string &value)
Parse a boolean value.
swarmio::data::Variant _value
Value.
Definition: ConstantField.h:21
Serializer is the base class for all binary message interpreters.
Definition: Serializer.h:17
Field for constant values.
Definition: ConstantField.h:13
virtual uint32_t CalculateSerializedLength(const swarmio::data::Variant &value, const FieldStack &fieldStack) const override
Calculate the length of a serialized message in bytes.
virtual swarmio::data::Variant Deserialize(ros::serialization::IStream &stream, const FieldStack &fieldStack) const override
Deserialize a stream into a variant.
virtual void WriteDefinition(std::stringstream &stream, bool forHash) const override
Write the definition of this field to a string stream.
ConstantField(const std::string &name, const Serializer &serializer, const std::string &value)
Construct a new ConstantField object.
void ParseUnsigned(const std::string &value)
Parse an unsigned integer value.
std::string _rawValue
Raw string value.
Definition: ConstantField.h:27


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