@@ -365,6 +365,20 @@ namespace sdf
365365 // / names. Also return true if no elements of the specified type are found.
366366 public: bool HasUniqueChildNames (const std::string &_type = " " ) const ;
367367
368+ // / \brief Checks whether any child elements of the specified element type,
369+ // / except those listed in \p _ignoreElements, have identical name attribute
370+ // / values and returns false if so.
371+ // / \param[in] _type The type of Element to check. If empty, check names
372+ // / of all child elements.
373+ // / \param[in] _ignoreElements A list of child element types to ignore when
374+ // / checking for uniqueness.
375+ // / \return True if all child elements with name attributes of the
376+ // / specified type have unique names, return false if there are duplicated
377+ // / names. Also return true if no elements of the specified type are found.
378+ public: bool HasUniqueChildNames (
379+ const std::string &_type,
380+ const std::vector<std::string> &_ignoreElements) const ;
381+
368382 // / \brief Count the number of child elements of the specified element type
369383 // / that have the same name attribute value.
370384 // / \param[in] _type The type of Element to check. If empty, count names
@@ -375,6 +389,20 @@ namespace sdf
375389 public: std::map<std::string, std::size_t >
376390 CountNamedElements (const std::string &_type = " " ) const ;
377391
392+ // / \brief Count the number of child elements of the specified element type
393+ // / that have the same name attribute value with the exception of elements
394+ // / listed in \p _ignoreElements.
395+ // / \param[in] _type The type of Element to check. If empty, count names
396+ // / of all child elements.
397+ // / \param[in] _ignoreElements A list of child element types to ignore when
398+ // / checking for uniqueness.
399+ // / \return Map from Element names to a count of how many times the name
400+ // / occurs. The count should never be 0. If all 2nd values are 1, then
401+ // / there are exclusively unique names.
402+ public: std::map<std::string, std::size_t > CountNamedElements (
403+ const std::string &_type,
404+ const std::vector<std::string> &_ignoreElements) const ;
405+
378406 // / \brief Return a pointer to the child element with the provided name.
379407 // /
380408 // / A new child element, with the provided name, is added to this element
@@ -482,6 +510,11 @@ namespace sdf
482510 // / \return A pointer to the named element if found, nullptr otherwise.
483511 public: ElementPtr GetElementImpl (const std::string &_name) const ;
484512
513+ // / \brief List of elements to which exceptions are made when checking for
514+ // / name uniqueness.
515+ // / \return List of element types that are allowed to have name collisions.
516+ public: static std::vector<std::string> NameUniquenessExceptions ();
517+
485518 // / \brief Generate a string (XML) representation of this object.
486519 // / \param[in] _prefix arbitrary prefix to put on the string.
487520 // / \param[in] _includeDefaultElements flag to include default elements.
0 commit comments