From b4764ff48045dac6f6a84ba0e296f1f37ae5eeb7 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Mon, 24 Apr 2023 22:02:28 -0700 Subject: [PATCH] Adds GetAttributeLabelsInGroup. --- sbf-cpp/Attributes.cpp | 19 +++++++++++++++++++ sbf-cpp/Attributes.h | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/sbf-cpp/Attributes.cpp b/sbf-cpp/Attributes.cpp index 1e2de44..ce3ccea 100644 --- a/sbf-cpp/Attributes.cpp +++ b/sbf-cpp/Attributes.cpp @@ -5,7 +5,10 @@ #include namespace SBF { +namespace { using std::string; +using std::vector; +} // End namespace string GetAttributeGroupLabel(int attributeGroupId) { if (attributeGroupId > 0 && attributeGroupId <= kAttributeGroupsCount) { @@ -116,6 +119,22 @@ void FillAttributeLabelsInGroup(std::vector& labels, int groupId) { } } +vector GetAttributeLabelsInGroup(int group_id) { + vector labels; + switch (group_id) { + case kAttributeGroupPhysicalId: + FillPhysicalAttributeLabels(labels); + break; + case kAttributeGroupSocialId: + FillSocialAttributeLabels(labels); + break; + case kAttributeGroupMentalId: + FillMentalAttributeLabels(labels); + break; + } + return labels; +} + void FillPhysicalAttributeLabels(std::vector& labels) { labels.clear(); for (int id = 1; id <= kPhysicalAttributesCount; id++) { diff --git a/sbf-cpp/Attributes.h b/sbf-cpp/Attributes.h index 13da2b0..4f53cbb 100644 --- a/sbf-cpp/Attributes.h +++ b/sbf-cpp/Attributes.h @@ -159,6 +159,11 @@ void FillAttributeGroupLabels(std::vector& labels); /// @param group_id The group to fill attribute labels for. void FillAttributeLabelsInGroup(std::vector& labels, int group_id); +/// @brief Gets the valid attribute labels in a specific group. +/// @param group_id The group to fill attribute labels for. +/// @return The filled vector. +std::vector GetAttributeLabelsInGroup(int group_id); + /// @brief Fills the provided vector with all of the valid physical attribute labels. /// @param labels The vector to fill. It will be cleared first. void FillPhysicalAttributeLabels(std::vector& labels);