Skip to content

Support for C++ dynamic allocated arrays #59

Description

@gastald88

I am dealing with a C++ legacy class representing a segment, say MySegment.
This class stores the segment's extremes data in a raw dynamic array, in fact it looks like this:

class MySegment
{
public:
	MySegment(double x1, double x2, double y1, double y2)
	{
		data = new double[4];
		
		data[0] = x1;
		data[1] = x2;
		data[2] = y1;
		data[3] = y2;
	}
	~MySegment()
	{
		delete[] data;
	}
private:
	double* data;
};

I tried to create the custom geometry view as similar examples show:

<Segment Type="MySegment">
	<Coordinates>
		<FirstX>data[0]</FirstX>
		<FirstY>data[1]</FirstY>
		<SecondX>data[2]</SecondX>
		<SecondY>data[3]</SecondY>
	</Coordinates>
</Segment>

Anyway this approach does not work.
Then, I tried to substitute the dynamic allocated array with a static one, so the segment class is now:

class MySegment
{
public:
	MySegment(double x1, double x2, double y1, double y2)
	{
		data[0] = x1;
		data[1] = x2;
		data[2] = y1;
		data[3] = y2;
	}
private:
	double data[4];
};

In this way the geometry view works fine, so it looks like the issue is only related to raw dynamic arrays.

Is there some trick to deal with such type of structures, or the support for now is missing?

Thank you

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions