Welcome, Guest
Guest Settings
Help

Thread: C++ Header to Delphi (HeadConv?)



Permlink Replies: 8 - Last Post: Mar 24, 2017 7:29 AM Last Post By: Andy Colmes
Andy Colmes

Posts: 91
Registered: 2/5/98
C++ Header to Delphi (HeadConv?)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 19, 2017 8:29 AM
I am trying to convert a few C++ Header files to Delphi. Is there a
tool that can do that? I came across HeadConv from Dr. Bob, but I am
not sure how to use it since it seems to only do that for DLL files. An
example of this header file is as follows:

Any help is greatly appreciated.

Jim

class TDescContainer
{
public:
struct descContainer
{
keypointsData kp;
TIERectangle rect;
};
TDescContainer(void) {CellSize = 0; Cell = 0;}
virtual ~TDescContainer(void) {ClearCells(); }
void ClearCells(void)
{
if (Cell)
{
for (int i = 0; i < CellSize; i++)
{
delete []Cell[i].kp.Data;
Cell[i].kp.Data = 0;
}
delete []Cell;
}
Cell = 0;
CellSize = 0;
}
void CreateCells(int size)
{
ClearCells();
CellSize = size;
Cell = new descContainer[size];
for (int i = 0; i < CellSize; i++)
{
Cell[i].kp.Data = 0;
Cell[i].kp.Count = 0;
}
}
void CreateData(int cIndex, int size)
{
if (Cell[cIndex].kp.Data)
delete [] Cell[cIndex].kp.Data;
Cell[cIndex].kp.Data = new keypoint[size];
Cell[cIndex].kp.Count = size;
}
descContainer *Cell;
int CellSize;
};

class TMatchContainer
{
public:
struct matchContainer
{
matchData md;
TIERectangle rect;
};
TMatchContainer(void) {CellSize = 0; Cell = 0; OffsetX = 0; }
virtual ~TMatchContainer(void) {ClearCells(); }
void ClearCells(void)
{
if (Cell)
{
for (int i = 0; i < CellSize; i++)
{
delete []Cell[i].md.Data;
Cell[i].md.Data = 0;
}
delete []Cell;
}
Cell = 0;
CellSize = 0;
OffsetX = 0;
}
void CreateCells(int size, int offsetX)
{
ClearCells();
OffsetX = offsetX;
CellSize = size;
Cell = new matchContainer[size];
for (int i = 0; i < CellSize; i++)
{
Cell[i].md.Data = 0;
Cell[i].md.Count = 0;
}
}
void CreateData(int cIndex, int size)
{
if (Cell[cIndex].md.Data)
delete [] Cell[cIndex].md.Data;
Cell[cIndex].md.Data = new matchings[size];
Cell[cIndex].md.Count = size;
}
matchContainer *Cell;
int CellSize;
int OffsetX;
};

class TAssistorBasic
{
protected:
TImageEnVect *_paint;
int *_hAssistorObject, _hAssistorSize, _hAssistorIndex;
int _boxID;
TAssistorType _assType;
public:
TAssistorBasic(TImageEnVect *paint);
virtual ~TAssistorBasic(void);
//
virtual void Add(int hobj, bool anchorToLayer = true);
virtual void Delete(void);
virtual void Create(int rows, int cols, int penSize, TColor
penColor);
virtual void Create(TDescContainer &dscC, int sigma, int
penSize, TColor penColor);
virtual void Create(TMatchContainer &matC, int index, int
penSize, TColor penColor);
virtual int Load(TDescContainer &dscC, int penSize, TColor
penColor, TColor brushColor);
virtual void PrepareAddObject(int penSize, TColor penColor,
TColor brushColor);
virtual void PrepareMoveObject(void);
virtual void DeleteObject(void);
virtual void Hide(bool full = false);
virtual void Show(bool full = false);
virtual TIERectangle GetObjRect(int val);
// properites
__property int Size = {read = _hAssistorSize};
__property int *Object = {read = _hAssistorObject};
__property TAssistorType Type = {read = _assType};
};

Rudy Velthuis (...


Posts: 6,536
Registered: 9/22/99
Re: C++ Header to Delphi (HeadConv?)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 19, 2017 9:22 AM   in response to: Andy Colmes in response to: Andy Colmes
Andy Colmes wrote:

I am trying to convert a few C++ Header files to Delphi. Is there a
tool that can do that? I came across HeadConv from Dr. Bob, but I am
not sure how to use it since it seems to only do that for DLL files.

Most tools are there to be able to convert API headers, and these are
usually made to be consumable by C and C++. That means that the header
conversion tools generally understand C and only a little C++ (only
enough to know what to avoid). HEADCONV is a nice tool, but it won't be
able to convert more spohisticated headers with lots of ifdefs, uuid
declarations, declspec declarations, interface declrations, etc.etc.

You probably won't find a good tool to easily and automatically convert
C++ headers (e.g. with classes, templates, and what-not) to Delphi, I
guess. But even if you could find one, how would you use the classes?

There is some help, though:

Conversion Helper Package:
http://rvelthuis.de/programs/convertpack.html

Using C++ objects in Delphi:
http://rvelthuis.de/articles/articles-cppobjs.html

But it will take quite some manual work. I found the simple macro
recording tool in the IDE to be useful for such conversions too, e.g.
to convert C-style declarations etc. to Delphi-style, etc.
--
Rudy Velthuis http://www.rvelthuis.de

Conway's Law: In any organization there will always be one person
who knows what is going on. This person must be fired.
Andy Colmes

Posts: 91
Registered: 2/5/98
Re: C++ Header to Delphi (HeadConv?)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 19, 2017 1:47 PM   in response to: Rudy Velthuis (... in response to: Rudy Velthuis (...
Hello Rudy,

Thank you for the response and for the resources on the subject.

The C++ Code is from C++ Builder and I do have the source and the Obj
files. I heard that it is possible to link the Obj files from C++
Builder to Delphi but pas wrappers are still needed. Would that be
easier in my case to do that if it is possible at all rather than
converting the entire C++ code to Delphi?

Thanks again Rudy.

Jim

Rudy Velthuis (TeamB) <newsgroups at rvelthuis dot de> wrote in message
news:911647 at forums dot embarcadero dot com

Andy Colmes wrote:

I am trying to convert a few C++ Header files to Delphi. Is there a
tool that can do that? I came across HeadConv from Dr. Bob, but I
am
not sure how to use it since it seems to only do that for DLL
files.

Most tools are there to be able to convert API headers, and these are
usually made to be consumable by C and C++. That means that the
header
conversion tools generally understand C and only a little C++ (only
enough to know what to avoid). HEADCONV is a nice tool, but it won't
be
able to convert more spohisticated headers with lots of ifdefs, uuid
declarations, declspec declarations, interface declrations, etc.etc.

You probably won't find a good tool to easily and automatically
convert
C++ headers (e.g. with classes, templates, and what-not) to Delphi, I
guess. But even if you could find one, how would you use the classes?

There is some help, though:

Conversion Helper Package:
http://rvelthuis.de/programs/convertpack.html

Using C++ objects in Delphi:
http://rvelthuis.de/articles/articles-cppobjs.html

But it will take quite some manual work. I found the simple macro
recording tool in the IDE to be useful for such conversions too, e.g.
to convert C-style declarations etc. to Delphi-style, etc.
--
Rudy Velthuis http://www.rvelthuis.de

Conway's Law: In any organization there will always be one person
who knows what is going on. This person must be fired.
Rudy Velthuis (...


Posts: 6,536
Registered: 9/22/99
Re: C++ Header to Delphi (HeadConv?)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 19, 2017 2:32 PM   in response to: Andy Colmes in response to: Andy Colmes
Andy Colmes wrote:

Hello Rudy,

Thank you for the response and for the resources on the subject.

The C++ Code is from C++ Builder and I do have the source and the Obj
files. I heard that it is possible to link the Obj files from C++
Builder to Delphi but pas wrappers are still needed. Would that be
easier in my case to do that if it is possible at all rather than
converting the entire C++ code to Delphi?

If you are unlucky, C++Builder does not even generate .obj files that
can be linked with Delphi anymore. AFAIK, the new 32 bit C++ and the 64
bit C++ compiler generate ELF files (but I could be wrong, please check
this yourself). Also, using these classes could work, but it could
just as well not. If they don't descend from TObject, chances are you
can't.

C++Builder can easily use Delphi classes. The other way around is much
harder or near impossible, unless you create COM wrappers or C wrappers
for your C++ classes.

And you are on your own too, if you want to generate .pas files from
your headers. There is no automated tool for that, AFAIK.

--
Rudy Velthuis http://www.rvelthuis.de

"Because I do it with one small ship, I am called a terrorist
(pirate?). You do it with a whole fleet and are called an
emperor."
-- St. Augustine
Andy Colmes

Posts: 91
Registered: 2/5/98
Re: C++ Header to Delphi (HeadConv?)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 23, 2017 7:51 PM   in response to: Rudy Velthuis (... in response to: Rudy Velthuis (...
Thanks Rudy for your insight.

Jim

Rudy Velthuis (TeamB) <newsgroups at rvelthuis dot de> wrote in message
news:911686 at forums dot embarcadero dot com

Andy Colmes wrote:

Hello Rudy,

Thank you for the response and for the resources on the subject.

The C++ Code is from C++ Builder and I do have the source and the
Obj
files. I heard that it is possible to link the Obj files from C++
Builder to Delphi but pas wrappers are still needed. Would that be
easier in my case to do that if it is possible at all rather than
converting the entire C++ code to Delphi?

If you are unlucky, C++Builder does not even generate .obj files that
can be linked with Delphi anymore. AFAIK, the new 32 bit C++ and the
64
bit C++ compiler generate ELF files (but I could be wrong, please
check
this yourself). Also, using these classes could work, but it could
just as well not. If they don't descend from TObject, chances are you
can't.

C++Builder can easily use Delphi classes. The other way around is
much
harder or near impossible, unless you create COM wrappers or C
wrappers
for your C++ classes.

And you are on your own too, if you want to generate .pas files from
your headers. There is no automated tool for that, AFAIK.

--
Rudy Velthuis http://www.rvelthuis.de

"Because I do it with one small ship, I am called a terrorist
(pirate?). You do it with a whole fleet and are called an
emperor."
-- St. Augustine
Rudy Velthuis (...


Posts: 6,536
Registered: 9/22/99
Re: C++ Header to Delphi (HeadConv?)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 24, 2017 5:38 AM   in response to: Andy Colmes in response to: Andy Colmes
Andy Colmes wrote:

Thanks Rudy for your insight.

Jim

Jim? I thought you were Andy Colmes? <g>

--
Rudy Velthuis http://www.rvelthuis.de

"There is no real wealth but the labor of man. Where the
mountains are of gold and the valleys of silver, the world
would not be one grain of corn the richer; not one comfort
would be added to the human race."
-- Percy B. Shelley

Andy Colmes

Posts: 91
Registered: 2/5/98
Re: C++ Header to Delphi (HeadConv?)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 24, 2017 7:29 AM   in response to: Rudy Velthuis (... in response to: Rudy Velthuis (...
I am sitting in for Andy for this project, who is recovering from an
illness :). He should be back next week.

Sorry for the confusion.

Jim.

Rudy Velthuis (TeamB) <newsgroups at rvelthuis dot de> wrote in message
news:912520 at forums dot embarcadero dot com

Andy Colmes wrote:

Thanks Rudy for your insight.

Jim

Jim? I thought you were Andy Colmes? <g>

--
Rudy Velthuis http://www.rvelthuis.de

"There is no real wealth but the labor of man. Where the
mountains are of gold and the valleys of silver, the world
would not be one grain of corn the richer; not one comfort
would be added to the human race."
-- Percy B. Shelley

Eli M

Posts: 1,221
Registered: 11/9/13
Re: C++ Header to Delphi (HeadConv?)
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 19, 2017 2:13 PM   in response to: Andy Colmes in response to: Andy Colmes
Andy Colmes

Posts: 91
Registered: 2/5/98
Re: C++ Header to Delphi (HeadConv?) [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 23, 2017 7:53 PM   in response to: Eli M in response to: Eli M
Thank you very much Eli for the resources.

Jim

Eli M <> wrote in message
news:911684 at forums dot embarcadero dot com

Couple different tools.

https://github.com/WouterVanNifterick/C-To-Delphi

The SWIG Delphi converter isn't 100% yet but you can usually work
through the issues it misses.
libraries-using-swig-with-delphi-support/
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02