aboutsummaryrefslogtreecommitdiffstats
path: root/lib/erl_interface/doc/src
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-03-06 15:13:34 +0100
committerSverker Eriksson <[email protected]>2014-03-06 20:10:19 +0100
commit6941af88ad016141f568279f065cb181074f1f9f (patch)
treebadef0333dd52b55a523f89d01a932a658e2f88c /lib/erl_interface/doc/src
parent453cba0046ec8363a4c3cea97ce22a6f4ff0b75a (diff)
downloadotp-6941af88ad016141f568279f065cb181074f1f9f.tar.gz
otp-6941af88ad016141f568279f065cb181074f1f9f.tar.bz2
otp-6941af88ad016141f568279f065cb181074f1f9f.zip
erl_interface: Add ei encode/decode for maps
Diffstat (limited to 'lib/erl_interface/doc/src')
-rw-r--r--lib/erl_interface/doc/src/ei.xml36
1 files changed, 35 insertions, 1 deletions
diff --git a/lib/erl_interface/doc/src/ei.xml b/lib/erl_interface/doc/src/ei.xml
index ab185c9179..1756ee8a7d 100644
--- a/lib/erl_interface/doc/src/ei.xml
+++ b/lib/erl_interface/doc/src/ei.xml
@@ -4,7 +4,7 @@
<cref>
<header>
<copyright>
- <year>2001</year><year>2013</year>
+ <year>2001</year><year>2014</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -417,6 +417,27 @@ ei_x_encode_empty_list(&amp;x);
</desc>
</func>
<func>
+ <name><ret>int</ret><nametext>ei_encode_map_header(char *buf, int *index, int arity)</nametext></name>
+ <name><ret>int</ret><nametext>ei_x_encode_map_header(ei_x_buff* x, int arity)</nametext></name>
+ <fsummary>Encode a map</fsummary>
+ <desc>
+ <p>This function encodes a map header, with a specified arity. The next
+ <c>arity</c> terms encoded will be the keys of the map, and the next
+ <c>arity</c> terms after that will be the corresponding values in
+ same order.</p>
+ <p>E.g. to encode the map <c>#{a => "Apple", b => "Banana"}</c>:</p>
+ <pre>
+ei_x_encode_map_header(&amp;x, 2);
+ei_x_encode_atom(&amp;x, "a");
+ei_x_encode_atom(&amp;x, "b");
+ei_x_encode_string(&amp;x, "Apple");
+ei_x_encode_string(&amp;x, "Banana");
+ </pre>
+ <p>A correctly encoded map can not have duplicate keys, but no check
+ for duplicate keys is done by this function.</p>
+ </desc>
+ </func>
+ <func>
<name><ret>int</ret><nametext>ei_get_type(const char *buf, const int *index, int *type, int *size)</nametext></name>
<fsummary>Fetch the type and size of an encoded term</fsummary>
<desc>
@@ -638,6 +659,19 @@ ei_x_encode_empty_list(&amp;x);
</desc>
</func>
<func>
+ <name><ret>int</ret><nametext>ei_decode_map_header(const char *buf, int *index, int *arity)</nametext></name>
+ <fsummary>Decode a map</fsummary>
+ <desc>
+ <p>This function decodes a map header from the binary
+ format. The number of key-value pairs is returned in
+ <c>arity</c>. Keys and values follows, first all keys and then all values,
+ which makes a total of <c>arity*2</c> terms.
+ Keys and values are paired according to their order, the first key
+ with the first value and so on. If <c>arity</c> is zero, it's an empty map.
+ A correctly encoded map does not have duplicate keys.</p>
+ </desc>
+ </func>
+ <func>
<name><ret>int</ret><nametext>ei_decode_ei_term(const char* buf, int* index, ei_term* term)</nametext></name>
<fsummary>Decode a term, without prior knowledge of type</fsummary>
<desc>