Commit d23e2894 authored by Hubert Figuiere's avatar Hubert Figuiere
Browse files

Added xmp_string_len().

parent b3607645
2.3.0
- New: API xmp_datetime_compare().
- New: API xmp_string_len() to get the length of the XmpString.
- Bug #94065:
- New: API xmp_files_can_put_xmp_xmpstring() and xmp_files_can_put_xmp_cstr()
variants.
......
/*
* exempi - exempi.cpp
*
* Copyright (C) 2007-2013 Hubert Figuiere
* Copyright (C) 2007-2016 Hubert Figuière
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -1120,7 +1120,11 @@ const char * xmp_string_cstr(XmpStringPtr s)
return reinterpret_cast<std::string*>(s)->c_str();
}
size_t xmp_string_len(XmpStringPtr s)
{
CHECK_PTR(s, 0);
return reinterpret_cast<const std::string *>(s)->size();
}
XmpIteratorPtr xmp_iterator_new(XmpPtr xmp, const char * schema,
const char * propName, XmpIterOptions options)
......
......@@ -82,16 +82,19 @@ int test_main(int argc, char *argv[])
BOOST_CHECK(xmp != NULL);
XmpStringPtr the_prop = xmp_string_new();
BOOST_CHECK(xmp_string_len(the_prop) == 0);
BOOST_CHECK(xmp_has_property(xmp, NS_TIFF, "Make"));
BOOST_CHECK(!xmp_has_property(xmp, NS_TIFF, "Foo"));
BOOST_CHECK(xmp_get_property(xmp, NS_TIFF, "Make", the_prop, NULL));
BOOST_CHECK(strcmp("Canon", xmp_string_cstr(the_prop)) == 0);
BOOST_CHECK(strcmp("Canon", xmp_string_cstr(the_prop)) == 0);
BOOST_CHECK(xmp_string_len(the_prop) == 5);
BOOST_CHECK(xmp_set_property(xmp, NS_TIFF, "Make", "Leica", 0));
BOOST_CHECK(xmp_get_property(xmp, NS_TIFF, "Make", the_prop, NULL));
BOOST_CHECK(strcmp("Leica", xmp_string_cstr(the_prop)) == 0);
BOOST_CHECK(strcmp("Leica", xmp_string_cstr(the_prop)) == 0);
BOOST_CHECK(xmp_string_len(the_prop) == 5);
uint32_t bits;
BOOST_CHECK(xmp_get_property(xmp, NS_DC, "rights[1]/?xml:lang",
......
......@@ -695,6 +695,11 @@ void xmp_string_free(XmpStringPtr s);
*/
const char * xmp_string_cstr(XmpStringPtr s);
/** Get the string length from the XmpStringPtr
* @param s the string object
* @return the string length. The unerlying implementation has it.
*/
size_t xmp_string_len(XmpStringPtr s);
/** Create a new iterator.
* @param xmp the packet
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment