Skip to content
Permalink
Browse files

Add expression functions for arrays and maps

  • Loading branch information
Patrick Valsecchi authored and pvalsecc committed Sep 20, 2016
1 parent cd1d44b commit f622c5bf2c2e460561033482f31b622e0dad88d8
@@ -51,6 +51,8 @@ scripts/astyle.exe
scripts/Debug
scripts/qgisstyle*
scripts/RelWithDebInfo
src/core/qgscontexthelp_texts.cpp
src/core/qgsexpression_texts.cpp
tests/testdata/cache/
tests/testdata/checker360by180.asc.aux.xml
tests/testdata/grass/wgs84/test/.gislock
@@ -0,0 +1,12 @@
{
"name": "array",
"type": "function",
"description": "Returns an array containing all the values passed as parameter.",
"variableLenArguments": true,
"arguments": [
{"arg":"value1", "syntaxOnly": true},
{"arg":"value2", "syntaxOnly": true},
{"arg":"value", "descOnly": true, "description":"a value"}],
"examples": [ { "expression":"array(2,10)", "returns":"array: 2, 10"}
]
}
@@ -0,0 +1,8 @@
{
"name": "array_append",
"type": "function",
"description": "Returns an array with the given value added at the end.",
"arguments": [ {"arg":"array","description":"an array"},
{"arg":"value","description":"the value to add"}],
"examples": [ { "expression":"array_append(array(1,2,3),4)", "returns":"array: 1,2,3,4"}]
}
@@ -0,0 +1,12 @@
{
"name": "array_cat",
"type": "function",
"description": "Returns an array containing all the given arrays concatenated.",
"variableLenArguments": true,
"arguments": [
{"arg":"array1", "syntaxOnly": true},
{"arg":"array2", "syntaxOnly": true},
{"arg":"array", "descOnly": true, "description":"an array"}],
"examples": [ { "expression":"array_cat(array(1,2),array(2,3))", "returns":"array: 1,2,2,3"}
]
}
@@ -0,0 +1,8 @@
{
"name": "array_contains",
"type": "function",
"description": "Returns true if an array contains the given value.",
"arguments": [ {"arg":"array","description":"an array"},
{"arg":"value","description":"the value to search"}],
"examples": [ { "expression":"array_contains(array(1,2,3),2)", "returns":"true"}]
}
@@ -0,0 +1,8 @@
{
"name": "array_find",
"type": "function",
"description": "Returns the index (0 for the first one) of a value within an array. Returns -1 if the value is not found.",
"arguments": [ {"arg":"array","description":"an array"},
{"arg":"value","description":"the value to search"}],
"examples": [ { "expression":"array_find(array(1,2,3),2)", "returns":"1"}]
}
@@ -0,0 +1,8 @@
{
"name": "array_get",
"type": "function",
"description": "Returns the Nth value (0 for the first one) of an array.",
"arguments": [ {"arg":"array","description":"an array"},
{"arg":"index","description":"the index to get (0 based)"}],
"examples": [ { "expression":"array_get(array('a','b','c'),1)", "returns":"'b'"}]
}
@@ -0,0 +1,9 @@
{
"name": "array_insert",
"type": "function",
"description": "Returns an array with the given value added at the given position.",
"arguments": [ {"arg":"array","description":"an array"},
{"arg":"pos","description":"the position where to add (0 based"},
{"arg":"value","description":"the value to add"}],
"examples": [ { "expression":"array_insert(array(1,2,3),1,100)", "returns":"array: 1,100,2,3"}]
}
@@ -0,0 +1,8 @@
{
"name": "array_intersect",
"type": "function",
"description": "Returns true if any element of array1 exists in array2.",
"arguments": [ {"arg":"array1","description":"an array"},
{"arg":"array2","description":"an other array"}],
"examples": [ { "expression":"array_intersect(array(1,2,3,4),array(4,0,2,5))", "returns":"true"}]
}
@@ -0,0 +1,7 @@
{
"name": "array_length",
"type": "function",
"description": "Returns the number of elements of an array.",
"arguments": [ {"arg":"array","description":"an array"}],
"examples": [ { "expression":"array_length(array(1,2,3))", "returns":"3"}]
}
@@ -0,0 +1,8 @@
{
"name": "array_prepend",
"type": "function",
"description": "Returns an array with the given value added at the begining.",
"arguments": [ {"arg":"array","description":"an array"},
{"arg":"value","description":"the value to add"}],
"examples": [ { "expression":"array_prepend(array(1,2,3),0)", "returns":"array: 0,1,2,3"}]
}
@@ -0,0 +1,8 @@
{
"name": "array_remove_all",
"type": "function",
"description": "Returns an array with all the entries of the given value removed.",
"arguments": [ {"arg":"array","description":"an array"},
{"arg":"value","description":"the value to add"}],
"examples": [ { "expression":"array_remove_all(array('a','b','c','b'),'b')", "returns":"array: 'a','c'"}]
}
@@ -0,0 +1,8 @@
{
"name": "array_remove_at",
"type": "function",
"description": "Returns an array with the given index removed.",
"arguments": [ {"arg":"array","description":"an array"},
{"arg":"pos","description":"the position to remove (0 based"}],
"examples": [ { "expression":"array_remove_at(array(1,2,3),1)", "returns":"array: 1,3"}]
}
@@ -0,0 +1,15 @@
{
"name": "map",
"type": "function",
"description": "Returns a map containing all the keys and values passed as pair of parameters.",
"variableLenArguments": true,
"arguments": [
{"arg":"key1", "syntaxOnly": true},
{"arg":"value1", "syntaxOnly": true},
{"arg":"key2", "syntaxOnly": true},
{"arg":"value2", "syntaxOnly": true},
{"arg":"key", "descOnly": true, "description":"a key (string)"},
{"arg":"value", "descOnly": true, "description":"a value"}],
"examples": [ { "expression":"map('1','one','2', 'two')", "returns":"map: 1: 'one', 2: 'two'"}
]
}
@@ -0,0 +1,7 @@
{
"name": "map_akeys",
"type": "function",
"description": "Returns all the keys of a map as an array.",
"arguments": [ {"arg":"map","description":"a map"}],
"examples": [ { "expression":"map_akeys(map('1','one','2','two'))", "returns":"array: '1', '2'"}]
}
@@ -0,0 +1,7 @@
{
"name": "map_avals",
"type": "function",
"description": "Returns all the values of a map as an array.",
"arguments": [ {"arg":"map","description":"a map"}],
"examples": [ { "expression":"map_avals(map('1','one','2','two'))", "returns":"array: 'one', 'two'"}]
}
@@ -0,0 +1,12 @@
{
"name": "map_concat",
"type": "function",
"description": "Returns a map containing all the entries of the given map. If two maps contain the same key, the value of the second map is taken.",
"variableLenArguments": true,
"arguments": [
{"arg":"map1", "syntaxOnly": true},
{"arg":"map2", "syntaxOnly": true},
{"arg":"map", "descOnly": true, "description":"a map"}],
"examples": [ { "expression":"map_concat(map('1','one', '2','overriden'),map('2','two', '3','three'))", "returns":"map: 1: 'one, 2: 'two', 3: 'three'"}
]
}
@@ -0,0 +1,8 @@
{
"name": "map_delete",
"type": "function",
"description": "Returns a map with the given key and its corresponding value deleted.",
"arguments": [ {"arg":"map","description":"a map"},
{"arg":"key","description":"the key to delete"}],
"examples": [ { "expression":"map_delete(map('1','one','2','two'),'2')", "returns":"map: 1: 'one'"}]
}
@@ -0,0 +1,8 @@
{
"name": "map_exist",
"type": "function",
"description": "Returns true if the given key exists in the map.",
"arguments": [ {"arg":"map","description":"a map"},
{"arg":"key","description":"the key to lookup"}],
"examples": [ { "expression":"map_exist(map('1','one','2','two'),'3')", "returns":"false"}]
}
@@ -0,0 +1,8 @@
{
"name": "map_get",
"type": "function",
"description": "Returns the value of a map, given it's key.",
"arguments": [ {"arg":"map","description":"a map"},
{"arg":"key","description":"the key to lookup"}],
"examples": [ { "expression":"map_get(map('1','one','2','two'),'2')", "returns":"'two'"}]
}
@@ -0,0 +1,9 @@
{
"name": "map_insert",
"type": "function",
"description": "Returns a map with an added key/value.",
"arguments": [ {"arg":"map","description":"a map"},
{"arg":"key","description":"the key to add"},
{"arg":"value","description":"the value to add"}],
"examples": [ { "expression":"map_insert(map('1','one'),'3','three')", "returns":"map: 1: 'one', 3: 'three'"}]
}

0 comments on commit f622c5b

Please sign in to comment.
You can’t perform that action at this time.