Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for C++ dynamic allocated arrays #59

Open
gastald88 opened this issue Nov 20, 2023 · 0 comments
Open

Support for C++ dynamic allocated arrays #59

gastald88 opened this issue Nov 20, 2023 · 0 comments

Comments

@gastald88
Copy link
Contributor

gastald88 commented Nov 20, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant