<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">On 12/12/12 11:08 AM, Olle E. Johansson
wrote:<br>
</div>
<blockquote
cite="mid:4858C4CF-C4C8-4ACE-88A8-727FEBF1BC6F@edvina.net"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<br>
<div>
<div>12 dec 2012 kl. 10:44 skrev Daniel-Constantin Mierla <<a
moz-do-not-send="true" href="mailto:miconda@gmail.com">miconda@gmail.com</a>>:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<div bgcolor="#FFFFFF" text="#000000"> Hello,<br>
<br>
<div class="moz-cite-prefix">On 10/9/12 3:59 PM, Andreas
Granig wrote:<br>
</div>
<blockquote cite="mid:50742DDD.1010202@sipwise.com"
type="cite">
<pre wrap="">Hi,
I'm playing around with xavp, but there are some things I can't wrap my
head around.
What basically works is this:
$xavp(a=>foo) = 'foo';
$xavp(a[0]=>bar) = 'bar';
Getting the value like this:
xlog("L_INFO", "a-foo='$xavp(a=>foo)' and a-bar='$xavp(a=>bar)'");
as well as
xlog("L_INFO", "a-foo='$xavp(a[0]=>foo)' and a-bar='$xavp(a[0]=>bar)'");
... works, because when omitting the index, it assumes [0]. I really
like to avoid such implicit assumptions though, to make the config
really clear, so I prefer the second approach.
What doesn't work for me then is explicit assignment of the very first
value, like this:
$xavp(a[0]=>foo) = 'foo';
$xavp(a[0]=>bar) = 'bar';
If I do this, the "a" xavp is never created. Wouldn't it be good
practice to create the xavp on first assignment? That way, I don't have
to take care in the config file whether the xavp is used for the first
time, where I have to omit the index.</pre>
</blockquote>
<br>
xavps are reusing the avps architecture in regards of
working as a stack. So last added is first in the list.<br>
<br>
The problem of creating the structure when providing the
index is also related to it. What should happen if one does:<br>
<br>
<pre wrap="">$xavp(a[5]=>foo) = 'foo';</pre>
<br>
Create other 5 xavps named 'a' (indexes 0 to 4)?<br>
<br>
It seemed the right approach not to create new structures at
invalid position, by simply not providing the position. For
overwriting a value, the index has to be provided.<br>
<br>
The xavps system was under rfc at some point:<br>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://lists.sip-router.org/pipermail/users/2009-July/024180.html">http://lists.sip-router.org/pipermail/users/2009-July/024180.html</a><br>
<br>
Of course, it can be adjusted when something can be better,
for the moment I don't see a solution to this case, unless a
new operator is introduced.<br>
<br>
<blockquote cite="mid:50742DDD.1010202@sipwise.com"
type="cite">
<pre wrap="">What I'm also wondering is whether it's possible to directly access
nested xavps, like this:
$xavp(a=>foo) = 'afoo';
$xavp(b=>foo) = 'bfoo';
$xavp(c=>a) = $xavp(a);
$xavp(c=>b) = $xavp(b);
xlog("L_INFO", "a-foo='$xavp(c=>a[0]=>foo)'");
or
xlog("L_INFO", "a-foo='$xavp(c=>a=>foo)'");
Both ways give me "a-foo='<<xavp:0x7f0d387fe178>>'". Is this even
intended? Would be really cool if that's possible!</pre>
</blockquote>
Internally it is possible to have as many nested xavps (the
value for an xavp can be a list of xavps). At this moment,
the config file syntax has support only for two levels, your
example is returning the value of c=>a, which is a
pointer to another xavp list.<br>
</div>
</blockquote>
</div>
<br>
<div>A question I came up with yesterday evening:</div>
<div><br>
</div>
<div>I have an AVP with five values (0-4) called "jultomte".</div>
<div><br>
</div>
<div>Is there a way to assign the FULL avp - all five values - to
an xavp value?</div>
<div><br>
</div>
<div>Like:</div>
<div>xavp(xmas=>tree) = $avp(jultomte)[*];</div>
</blockquote>
The star index [*] for avps (also hdrs and xavps) returns all the
values in a comma separated string. So all five values will be
concatenated, with comma in between, the result will be stored as a
string value in the xavp.<br>
<br>
Cheers,<br>
Daniel<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a></pre>
</body>
</html>