# Working with stringlistop custom metadata

**URL:** <https://forum.aousd.org/t/working-with-stringlistop-custom-metadata/1710>\
**Category:** USD\
**Created:** [July 22, 2024, 9:33pm UTC](https://forum.aousd.org/t/working-with-stringlistop-custom-metadata/1710 "2024-07-22T21:33:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjzanin-SMS](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/jjzanin-sms/32/391_2.png) [@jjzanin-SMS](https://forum.aousd.org/u/jjzanin-SMS)\
**Post date:** [July 22, 2024, 9:33pm UTC](https://forum.aousd.org/t/working-with-stringlistop-custom-metadata/1710/1 "2024-07-22T21:33:36Z")

</div>

Hello,

We have a non-applied API schema with a string array metadata and thought that stringlistop would be better than string array. How do you work with stringlistop in C++? I saw there is a `SdfListEditorProxy` class in the USD API documentation and I found examples of it being used in the USD source. I think I want to use `SdfNameEditorProxy`, which is a typedef of `SdfListEditorProxy<SdfNameKeyPolicy>`, to work with an array of strings. I found that `SdfVariantSetNamesProxy` is a typedef of `SdfNameEditorProxy` and the `SdfPrimSpec::GetVariantSetNameList` function creates an instance with the following code:

```auto
SdfVariantSetNamesProxy
SdfPrimSpec::GetVariantSetNameList() const
{
    return SdfVariantSetNamesProxy(
        std::make_unique<Sdf_ListOpListEditor<SdfNameKeyPolicy>>(
            SdfCreateHandle(this), SdfFieldKeys->VariantSetNames));
}

```

I tried to do something similar but I am unable to include the file “listOpListEditor.h” for `Sdf_ListOpListEditor` because it is not installed. It is considered a “private class” in the CMakeLists.txt file for Sdf.

Is this the right direction?

Thank you,  
Jeremiah Zanin

---

<div class="post-metadata">

**Author:** ![spiff](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/spiff/32/22_2.png) [@spiff](https://forum.aousd.org/u/spiff)\
**Post date:** [July 22, 2024, 11:54pm UTC](https://forum.aousd.org/t/working-with-stringlistop-custom-metadata/1710/2 "2024-07-22T23:54:01Z")

</div>

[Here’s](https://github.com/PixarAnimationStudios/OpenUSD/blob/2864f3d04f396432f22ec5d6928fc37d34bb4c90/pxr/usd/sdf/listOp.h#L328) where SdfStringListOp is defined, and [here](https://github.com/PixarAnimationStudios/OpenUSD/blob/2864f3d04f396432f22ec5d6928fc37d34bb4c90/pxr/usd/usdGeom/pointInstancer.cpp#L428) is an example of using one of the other available list-types using the Usd and Sdf API’s together.

---

<div class="post-metadata">

**Author:** ![jjzanin-SMS](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/jjzanin-sms/32/391_2.png) [@jjzanin-SMS](https://forum.aousd.org/u/jjzanin-SMS)\
**Post date:** [July 23, 2024, 10:53pm UTC](https://forum.aousd.org/t/working-with-stringlistop-custom-metadata/1710/3 "2024-07-23T22:53:46Z")

</div>

Thank you for the information.

I noticed that if you call SetMetadata with a SdfStringListOp of appended items or prepended items and then call GetMetadata, you get an SdfStringListOp set to explicit and the explicit list is populated. I was expecting the same data back from GetMetadata as I gave to SetMetadata. Why is it set to explicit?

---

<div class="post-metadata">

**Author:** ![spiff](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/spiff/32/22_2.png) [@spiff](https://forum.aousd.org/u/spiff)\
**Post date:** [July 23, 2024, 11:17pm UTC](https://forum.aousd.org/t/working-with-stringlistop-custom-metadata/1710/4 "2024-07-23T23:17:47Z")

</div>

That was a decision we made at the outset, on the thinking that to a TD working with the data on a UsdStage, the effective value-type of that metadata is a string-array. And for _most_ workflows, you want the resolved result - if we returned just the strongest ListOp, it would be on each and every consumer to use some different API to instead do the full composing of all the opinions that contribute. So we always compute the “flattened” result and return it as an explicit ListOp. That could be documented better, and we could also provide API to fetch just the strongest Op, but is that needed? You _can_ fetch the UsdPrimStack and find the strongest yourself, fetching it with Sdf API’s if you really need to - will that work?

---

<div class="post-metadata">

**Author:** ![jjzanin-SMS](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/jjzanin-sms/32/391_2.png) [@jjzanin-SMS](https://forum.aousd.org/u/jjzanin-SMS)\
**Post date:** [July 24, 2024, 2:54pm UTC](https://forum.aousd.org/t/working-with-stringlistop-custom-metadata/1710/5 "2024-07-24T14:54:00Z")

</div>

Ah ok, that makes sense. Yes, if I need to use the Sdf API that’s fine.

Thanks!
