#define equivalent?
#1
This is probably more of a general XML question than XBMC specific, but I can't find and answer through google...

Is there an XML equivalent to #define in c/c++?

I've got some elements that I'd like to keep in sync without having to go through each individual file.

eg.
[HTML]<font>
<size>48</size>
</font>

<control list>
<layout height="48">
<label>
<height>48</height>
</label>
</layout>
</control>[/HTML]

but I'd like to have this (or something similar):[HTML]

<define name="MYFONTSIZE">48</define>

<font>
<size><? MYFONTSIZE ></size>
</font>

<control list>
<layout height="<? MYFONTSIZE >">
<label>
<height><? MYFONTSIZE ></height>
</label>
</layout>
</control>[/HTML]

I can't use 'includes' because they (seem to) need the appropriate tags as well as some data, in this case I'd need 3x includes, which is a bit better, but still a pain (not sure if include would work with the <layout> tag, do includes need to be a complete block? i.e. <layout height="48">..blah..</layout>, meaning I couldn't use it here anyway?)
Reply
#2
You'd have to have the entire block in includes.xml, yes. The label <height> tag can be specified in includes directly.

And no, there is no equivalent of #define in XML.

Something like this could possibly be added (some sort of <constant name="name_of_constant">number</constant> in an include perhaps?) I'd be interested to hear what other skinners have to say.

It would only work with numeric inputs, and they would be constant (at least while the window is onscreen, and it'd be my preference for them to be permanently constant).

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
I asked for a simular feature about 3 years ago. I called them 'templates' or you can think of them as layers. You could define templates that you could use as starting points for pages; or anything you want to keep constant through a set of pages (font sizes, image locations, etc). So in your pages you'd simply denote the templates at the top of the XML and anything else below would be added "over the top" of the templates - basically layering.

This would greatly reduce the size of XMLs that have much of the same images/placement and also speed up skin creation and modification.
I'm not an expert but I play one at work.
Reply
#4
jmarshall Wrote:Something like this could possibly be added (some sort of <constant name="name_of_constant">number</constant> in an include perhaps?) I'd be interested to hear what other skinners have to say.

This is exactly what I'm looking forSmile


jmarshall Wrote:It would only work with numeric inputs, and they would be constant (at least while the window is onscreen, and it'd be my preference for them to be permanently constant).

Ideally, any value would be nice (strings too) so that they can be used just like #define, and in any place but this would (probably?)need a sort of pre-processing step, especially if they're to be included in values as well as inside tags, ie.

<thing height="<ConstantX>">
as well as
<height><ConstantX></height>

I don't know enough about XML to say what *actually* needs to be doneSmile

either way, at least the numerical version would be wonderful and would save absolutely tons of time, (imo, since I have a lot of values that I need to keep synced, like the example above).
Reply
#5
Sure, strings could be done as well, though they're not really as important, as for one thing they're just about all includable in that regard.

I was just going to have the deciphering done in the GetFloat() and GetInteger() type routines (and make sure everything uses them!)

Format will simply be <height>name_of_define</height>, or height="name_of_define".

Defines will be done in an include file:

<constant name="name_of_define">number</constant>

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#6
jmarshall Wrote:Sure, strings could be done as well, though they're not really as important, as for one thing they're just about all includable in that regard.

Only reason I say do strings too is that *someone* will find a use for them, and I'm thinking in terms of #define's implementation in a c (pre-)compiler, i.e. it just replaces the DEFINE_NAME with (DEFINE_CONTENT) so I'd imagine excluding strings to be harder, but if you've got to parse the XML first before replacing then that might be a bit more work than just numbers.


jmarshall Wrote:I was just going to have the deciphering done in the GetFloat() and GetInteger() type routines (and make sure everything uses them!)

Format will simply be <height>name_of_define</height>, or height="name_of_define".

Defines will be done in an include file:

<constant name="name_of_define">number</constant>

Awesome!
Reply
#7
The current implementation works by keeping the constants in memory so that they can be in another file (eg includes.xml). A preprocessor needs to know all this stuff, so it's easier just to do it whenever we lookup a float value.

This rules out booleans, DWORDs (a few timing variables - mostly for multiimage), and strings.

The implementation is done - just need to check it actually works as desired.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#8
Revision 10266 has the magic. Let me know if it does all you want.

The manual is even up to date as well Smile
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#9
Superb! that was fastBig Grin
I'll have to wait till the next t3ch release since I've not got my own XDK, but that looks like it's just the job.

Thanks.
Reply
#10
Long time since I posted, I've just started working on my skin again and now I've got a more recent build, this is amazing, it works just like magic Big Grin

Thanks again!
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
#define equivalent?00