diff options
author | David Robillard <d@drobilla.net> | 2008-12-13 04:37:57 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-12-13 04:37:57 +0000 |
commit | c854c1f24f41844f0c95e8943738a820d8a283e5 (patch) | |
tree | cd192e47417aa4f6f9369b8f8922fb4af243cfc1 /src/value.c | |
parent | cfaf7d029da6f66bddfd91c7874d4019c502ea5c (diff) | |
download | lilv-c854c1f24f41844f0c95e8943738a820d8a283e5.tar.gz lilv-c854c1f24f41844f0c95e8943738a820d8a283e5.tar.bz2 lilv-c854c1f24f41844f0c95e8943738a820d8a283e5.zip |
Add constructors slv2_value_new_int, slv2_value_new_float, slv2_value_new_string.
Fix slv2_value_get_turtle_token for floats.
Nearly complete test coverage for value stuff: 73.5% coverage
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@1858 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/value.c')
-rw-r--r-- | src/value.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/value.c b/src/value.c index a8ef85a..0e474fb 100644 --- a/src/value.c +++ b/src/value.c @@ -141,6 +141,31 @@ slv2_value_new_uri(SLV2World world, const char* uri) SLV2Value +slv2_value_new_string(SLV2World world, const char* str) +{ + return slv2_value_new(world, SLV2_VALUE_STRING, str); +} + + +SLV2Value +slv2_value_new_int(SLV2World world, int val) +{ + char str[32]; + snprintf(str, 32, "%d", val); + return slv2_value_new(world, SLV2_VALUE_INT, str); +} + + +SLV2Value +slv2_value_new_float(SLV2World world, float val) +{ + char str[32]; + snprintf(str, 32, "%f", val); + return slv2_value_new(world, SLV2_VALUE_FLOAT, str); +} + + +SLV2Value slv2_value_duplicate(SLV2Value val) { SLV2Value result = (SLV2Value)malloc(sizeof(struct _SLV2Value)); @@ -229,7 +254,7 @@ slv2_value_get_turtle_token(SLV2Value value) len = 20; // FIXME: proper maximum value? result = calloc(len, sizeof(char)); setlocale(LC_NUMERIC, "POSIX"); - snprintf(result, len, ".1%f", value->val.float_val); + snprintf(result, len, "%f", value->val.float_val); setlocale(LC_NUMERIC, locale); break; } |