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:
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.
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?
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?