Class: Typelib::EnumType

Inherits:
Object
  • Object
show all
Defined in:
lib/orogen/gen/typekit.rb,
lib/orogen/marshallers/iostream.rb

Class Method Summary collapse

Class Method Details

.to_stream(typekit, result, indent) ⇒ Object



42
43
44
45
46
# File 'lib/orogen/marshallers/iostream.rb', line 42

def self.to_stream(typekit, result, indent)
    to_string(typekit, result, indent)
    result << "#{indent}io << enum_name;\n";
    result
end

.to_string(typekit, result, indent) ⇒ Object



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/orogen/gen/typekit.rb', line 181

def self.to_string(typekit, result, indent)
    seen_values = Set.new
    result << indent << "std::string enum_name;\n"
    result << indent << "switch(value) {\n"
    keys.each do |name, value|
        next if seen_values.include?(value)
        seen_values << value

        result << "#{indent}    case #{namespace('::')}#{name}:\n"
        result << "#{indent}      enum_name = \"#{name}\";\n"
        result << "#{indent}      break;\n"
    end

    result << <<-EOT
#{indent}    default:
#{indent}        RTT::log(RTT::Error) << "invalid value '" << (int)value << "' for enum '#{cxx_name}'" << RTT::endlog();
#{indent}        return false;
#{indent}}
    EOT
    result
end