Skip to content

Commit

Permalink
From review
Browse files Browse the repository at this point in the history
  • Loading branch information
sonndinh committed Feb 6, 2024
1 parent 84269c6 commit 8291f99
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions dds/DCPS/JsonValueWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class JsonValueWriter : public ValueWriter {
void end_array();
void begin_sequence(XTypes::TypeKind elem_kind = XTypes::TK_NONE, ACE_CDR::ULong length = 0);
void end_sequence();
void begin_element(size_t idx);
void begin_element(ACE_CDR::ULong idx);
void end_element();

void write_boolean(ACE_CDR::Boolean value);
Expand Down Expand Up @@ -168,7 +168,7 @@ void JsonValueWriter<Writer>::end_sequence()
}

template <typename Writer>
void JsonValueWriter<Writer>::begin_element(size_t /*idx*/)
void JsonValueWriter<Writer>::begin_element(ACE_CDR::ULong /*idx*/)
{}

template <typename Writer>
Expand Down
4 changes: 2 additions & 2 deletions dds/DCPS/PrinterValueWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PrinterValueWriter : public ValueWriter {
void end_array();
void begin_sequence(XTypes::TypeKind elem_tk = XTypes::TK_NONE, ACE_CDR::ULong length = 0);
void end_sequence();
void begin_element(size_t idx);
void begin_element(ACE_CDR::ULong idx);
void end_element();

void write_boolean(ACE_CDR::Boolean value);
Expand Down Expand Up @@ -167,7 +167,7 @@ void PrinterValueWriter::end_sequence()
current_indent_ -= indent_;
}

void PrinterValueWriter::begin_element(size_t idx)
void PrinterValueWriter::begin_element(ACE_CDR::ULong idx)
{
stream_ << newline() << std::string(current_indent_, ' ') << '[' << idx << "]: ";
at_newline_ = false;
Expand Down
14 changes: 7 additions & 7 deletions dds/DCPS/ValueWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,41 @@ struct VWriterMemberParam {
VWriterMemberParam()
: id()
, must_understand(0)
, name(0)
, optional(false)
, present(true)
, name(0)
{}

VWriterMemberParam(unsigned m_id, bool m_must_understand)
: id(m_id)
, must_understand(m_must_understand)
, name(0)
, optional(false)
, present(true)
, name(0)
{}

VWriterMemberParam(const char* m_name)
: id(0)
, must_understand(false)
, name(m_name)
, optional(false)
, present(true)
, name(m_name)
{}

VWriterMemberParam(unsigned m_id, bool m_must_understand,
const char* m_name, bool m_optional, bool m_present)
: id(m_id)
, must_understand(m_must_understand)
, name(m_name)
, optional(m_optional)
, present(m_present)
, name(m_name)
{}

unsigned id;
bool must_understand;
const char* name;
bool optional;
bool present;
const char* name;
};

/// A ValueWriter receives events and values from the recitation of a
Expand Down Expand Up @@ -98,7 +98,7 @@ class OpenDDS_Dcps_Export ValueWriter {
virtual void end_array() {}
virtual void begin_sequence(XTypes::TypeKind /*elem_kind*/, ACE_CDR::ULong /*length*/) {}
virtual void end_sequence() {}
virtual void begin_element(size_t /*idx*/) {}
virtual void begin_element(ACE_CDR::ULong /*idx*/) {}
virtual void end_element() {}

virtual void write_boolean(ACE_CDR::Boolean /*value*/) = 0;
Expand Down Expand Up @@ -145,7 +145,7 @@ class OpenDDS_Dcps_Export ValueWriter {
#endif
}

virtual void write_enum(const char* /*name*/, ACE_CDR::Long /*value*/, XTypes::TypeKind /*as_int*/) = 0;
virtual void write_enum(const char* name, ACE_CDR::Long value, XTypes::TypeKind as_int) = 0;
template <typename T>
void write_enum(const char* name, const T& value, XTypes::TypeKind as_int = XTypes::TK_INT32)
{
Expand Down
2 changes: 1 addition & 1 deletion dds/DCPS/Xcdr2ValueWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ void Xcdr2ValueWriter::end_sequence()
end_complex();
}

void Xcdr2ValueWriter::begin_element(size_t /*idx*/)
void Xcdr2ValueWriter::begin_element(ACE_CDR::ULong /*idx*/)
{
return;
}
Expand Down
9 changes: 7 additions & 2 deletions dds/DCPS/Xcdr2ValueWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <vector>
#include <stack>
#include <stdexcept>

OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL

Expand All @@ -18,7 +19,11 @@ class OpenDDS_Dcps_Export Xcdr2ValueWriter : public ValueWriter {
, encoding_(encoding)
, pos_(0)
, ser_(0)
{}
{
if (encoding.xcdr_version() != Encoding::XCDR_VERSION_2) {
throw std::runtime_error("Xcdr2ValueWriter only supports XCDR2");
}
}

void begin_struct(Extensibility extensibility);
void end_struct();
Expand All @@ -36,7 +41,7 @@ class OpenDDS_Dcps_Export Xcdr2ValueWriter : public ValueWriter {
void end_array();
void begin_sequence(XTypes::TypeKind elem_kind, ACE_CDR::ULong length);
void end_sequence();
void begin_element(size_t idx);
void begin_element(ACE_CDR::ULong idx);
void end_element();

void write_boolean(ACE_CDR::Boolean value);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/dds/DCPS/Xcdr2ValueWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void check_component_sizes(DCPS::Xcdr2ValueWriter& value_writer, const size_t* a
{
std::vector<size_t> expected_sizes(arr, arr + length);
const std::vector<size_t>& sizes = value_writer.get_serialized_sizes();
EXPECT_TRUE(expected_sizes == sizes);
EXPECT_EQ(expected_sizes, sizes);
}

template <typename Xtag, typename Type>
Expand Down

0 comments on commit 8291f99

Please sign in to comment.