Book a Demo

Author Topic: Code template question: filter destructor  (Read 3322 times)

Bokkie

  • EA User
  • **
  • Posts: 80
  • Karma: +0/-0
  • Lima Bravo!
    • View Profile
Code template question: filter destructor
« on: May 19, 2008, 11:43:56 pm »
Hello,

To filter constructors you can use:
Code: [Select]
%list="Operation" @separator="\n\n" @indent="\t" opName == className%
But how can filter out the destructor, as far as I know the condition on the list is evaluated in a separate context to the current template and therefore can't include variables.

Any ideas?

/m.
« Last Edit: May 19, 2008, 11:44:51 pm by Bokkie »
Lima Bravo!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code template question: filter destructor
« Reply #1 on: May 20, 2008, 08:43:47 am »
Code: [Select]
// Constructors
%list="Operation" @separator="\n\n" @indent="\t" opName == className%
// Destructor.
$destructor = "~" + %className%
%list="Operation" @separator="\n\n" @indent="\t" $destructor == opName%
// Everything else
%list="Operation" @separator="\n\n" @indent="\t" opName != className and $destructor != opName%

Bokkie

  • EA User
  • **
  • Posts: 80
  • Karma: +0/-0
  • Lima Bravo!
    • View Profile
Re: Code template question: filter destructor
« Reply #2 on: May 20, 2008, 04:13:03 pm »
Thanks, it works!

Still a question: before posting my question I tried:
Code: [Select]
%list="Operation" @separator="\n\n" @indent="\t" opName == $destructor%
This did not work, in your example, the filter is 'reversed': $destructor == opName.

What am I missing?

Kind regards,

/m.
Lima Bravo!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code template question: filter destructor
« Reply #3 on: May 21, 2008, 08:36:58 am »
Well, I think you were partially right.  The left hand term of the condition is evaluated in terms of the template that would be executed if the condition is met.  The right hand term is evaluated in the current template.

So, if you wrote the constructor filter the other way around it would probably fail too.