cfengine/core — pull request #1198 by cdituri (2013-12-15 09:20:17+00:00)
Title: Redmine#3279: datatype(), a function which returns the top-level type of a data container

Another data container function from the list in [redmine#3279](https://cfengine.com/dev/issues/3279#note-18).

Before I write the acceptance test I'd like to phone the language lawyers on ``const VarRef* const`` and the const-cast-away in ``VarRefDestroy()``... namely, does this result in Undefined Behavior? IOW, a no-no?

---

@tzz - does the ouput accurately reflect what you expect|described in the redmine link above?
```
⚡ root@dirtbox  /var/cfengine/inputs  cf-agent -Kf ./test.cf 2>&1 | grep "notice:"
2013-12-15T03:02:27-0600 notice: /test: R: test0 datatype(invalid): $(invalid_type)
2013-12-15T03:02:27-0600 notice: /test: R: test1 datatype(one): json_array
2013-12-15T03:02:27-0600 notice: /test: R: test2 datatype(two): json_object
2013-12-15T03:02:27-0600 notice: /test: R: test3 datatype(two[boolean]): json_bool
2013-12-15T03:02:27-0600 notice: /test: R: test3 datatype(two[string]): json_string
2013-12-15T03:02:27-0600 notice: /test: R: test3 datatype(two[integer]): json_integer
2013-12-15T03:02:27-0600 notice: /test: R: test3 datatype(two[list]): json_array
2013-12-15T03:02:27-0600 notice: /test: R: test3 datatype(two[object]): json_object
2013-12-15T03:02:27-0600 notice: /test: R: test3 datatype(two[integer2]): json_integer
2013-12-15T03:02:27-0600 notice: /test: R: test3 datatype(two[string2]): json_string
2013-12-15T03:02:27-0600 notice: /test: R: test3 datatype(two[boolean2]): json_bool
2013-12-15T03:02:27-0600 notice: /test: R: test3 datatype(two[null]): json_null
2013-12-15T03:02:27-0600 notice: /test: R: test4 datatype(two[object][a]): json_bool
2013-12-15T03:02:27-0600 notice: /test: R: test4 datatype(two[object][b]): json_array
2013-12-15T03:02:27-0600 notice: /test: R: test4 datatype(two[object][c]): json_string
2013-12-15T03:02:27-0600 notice: /test: R: test4 datatype(two[object][d]): json_integer
```
Note:
'invalid' was of type string and not a data container
'one' was a simple json: [5,4,3,2,1]
'two' is the same json data as feed to parsejson() [here](https://github.com/cfengine/core/blob/master/tests/acceptance/01_vars/02_functions/nth_datacontainer.cf#L96)