User Tools

Site Tools


cookbooks:5.3.x:pseudovariables

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
cookbooks:5.3.x:pseudovariables [2020/02/21 17:13]
btriller
cookbooks:5.3.x:pseudovariables [2020/04/02 21:32]
miconda [$xavp(id) - XAVPs]
Line 722: Line 722:
 ===== $xavp(id) - XAVPs ===== ===== $xavp(id) - XAVPs =====
  
-xavp - extended AVP'- are structures that can store multiple values. They work like a stack, much like AVPs, and are attached to SIP transactions. Each xavp has a name and can contain multiple named valuesthe structure name and the value name are separated by <nowiki>=></nowiki> like <nowiki>$xavp(root=>branch)</nowiki> where "root" is the name of the structure and branch is a named value. To assign a value use+**xavp** eXtended AVPs - are variables that can store multiple values, which can also be grouped in a structure-like fashion. Their value can be a string, an integer number or a list of named values. 
 + 
 +They work like a stack, similar to AVPs, and are attached to SIP transactions and automatically destroyed when the transaction is finished. 
 + 
 +Each xavp has a string name and can contain a stringand integer or a list of named value. The structure name (or root list name) and the value name (or field name) are separated by <nowiki>=></nowiki> like <nowiki>$xavp(root=>field)</nowiki> where "root" is the name of the structure and "field" is the name of the value. 
 + 
 +To assign a single value use
 <code c> <code c>
-$xavp(root=>branch)="value";+$xavp(root)="string value"; 
 +$xavp(root)=intnumber; 
 +</code> 
 + 
 +To assign a named value use: 
 + 
 +<code c> 
 +$xavp(root=>field)="string value"
 +$xavp(root=>field)=intnumber;
 </code> </code>
  
 Like avps, xavp act like a stack. To refer to an existing value, use an index. The newest xavp has index zero [0]. Like avps, xavp act like a stack. To refer to an existing value, use an index. The newest xavp has index zero [0].
 +
 <code c> <code c>
-$xavp(root[0]=>newbranch)=12;+$xavp(root[0]=>field)=12;
 </code> </code>
  
 If you assign a value without an index, a new xavp is allocated and the old one is pushed up the stack, becoming index [1]. Old index [1] becomes [2] etc. If you assign a value without an index, a new xavp is allocated and the old one is pushed up the stack, becoming index [1]. Old index [1] becomes [2] etc.
 +
 <code c> <code c>
 +# new item (example => (name = "one"))
 $xavp(example=>name)="one"; $xavp(example=>name)="one";
-#create new+add new item (example => (name = "two"))
 $xavp(example=>name)="two"; $xavp(example=>name)="two";
-#add extra value to "two"+# add another named value to the last example item
 $xavp(example[0]=>value)="John"; $xavp(example[0]=>value)="John";
-#add value to first variable - "one" +# add another named value to first example item 
-$xavp(example[1]=>value)="Anna";+xavp(example[1]=>value)="Anna";
 </code> </code>
  
cookbooks/5.3.x/pseudovariables.txt · Last modified: 2020/04/06 18:09 by pojogas