Skip to content

openrtm.orgでソースコードを貼り付けた場合に正常に表示されない #2

@Nobu19800

Description

@Nobu19800

Describe the bug
openrtm.orgで以下の手順でソースコードを貼り付けた場合に正常に表示されない場合がある。

To Reproduce
Steps to reproduce the behavior:

  1. openrtm.orgで以下のテキストを貼り付け
<cpp>
#include <rtm/ByteDataStreamBase.h>
#include <rtm/idl/BasicDataTypeSkel.h>
#include <coil/Factory.h>
#include <rtm/Manager.h>

template <class DataType>
class TestSerializer : public RTC::ByteDataStream<DataType>
{
public:
    TestSerializer():m_buffer(NULL), m_length(0){};

    virtual void writeData(const unsigned char* buffer, unsigned long length)
    {
        delete m_buffer;
        m_buffer = new unsigned char[length];
        memcpy(m_buffer, buffer, length);
        m_length = length;
    }
    virtual void readData(unsigned char* buffer, unsigned long length) const
    {
        if (m_buffer)
        {
            memcpy(buffer, m_buffer, length);
        }
    }
    virtual unsigned long getDataLength() const
    {
        return m_length;
    };
    virtual bool serialize(const DataType& data)
    {
        delete m_buffer;
        m_buffer = new unsigned char[1];
        m_buffer[0] = static_cast<unsigned char>(data.data);
        m_length = 1;
        return true;
    };
    virtual bool deserialize(DataType& data)
    {
        if (m_buffer)
        {
            data.data = static_cast<long>(m_buffer[0])+1;
            return true;
        }
        return false;
    };
private:
    unsigned char* m_buffer;
    unsigned long m_length;

};

extern "C"
{
    DLL_EXPORT void TestSerializerInit(RTC::Manager* manager)
    {
        coil::GlobalFactory <::RTC::ByteDataStream<RTC::TimedLong>>::
            instance().addFactory("test",
                ::coil::Creator< ::RTC::ByteDataStream<RTC::TimedLong>,
                TestSerializer<RTC::TimedLong>>,
                ::coil::Destructor< ::RTC::ByteDataStream<RTC::TimedLong>,
                TestSerializer<RTC::TimedLong>>);
    };
}
</cpp>
  1. プレビューで以下のように表示

image

Reproducibility
100%

Expected behavior

Screenshots or Logs

Environment

Additional context

Metadata

Metadata

Assignees

Labels

Web systemWeb system (CMS, etc.) functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions