From 005fcf7f565c2b853e14ba42b464fbd2661f1d00 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Mon, 24 Apr 2023 23:35:59 -0700 Subject: [PATCH] Adds GetBackgroundLabels. --- sbf-cpp/Backgrounds.cpp | 15 +++++++++++++-- sbf-cpp/Backgrounds.h | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sbf-cpp/Backgrounds.cpp b/sbf-cpp/Backgrounds.cpp index e97e1f3..df39226 100644 --- a/sbf-cpp/Backgrounds.cpp +++ b/sbf-cpp/Backgrounds.cpp @@ -4,17 +4,28 @@ #include namespace SBF { -std::string GetBackgroundLabel(int backgroundId) { +namespace { +using std::string; +using std::vector; +} // End namespace + +string GetBackgroundLabel(int backgroundId) { if (backgroundId > 0 && backgroundId <= kBackgroundsCount) { return kBackgroundLabels[backgroundId]; } return ""; } -void FillBackgroundLabels(std::vector& labels) { +void FillBackgroundLabels(vector& labels) { labels.clear(); for (int id = 1; id <= kBackgroundsCount; id++) { labels.push_back(kBackgroundLabels[id]); } } + +vector GetBackgroundLabels() { + vector labels; + FillBackgroundLabels(labels); + return labels; +} } // End namespace SBF diff --git a/sbf-cpp/Backgrounds.h b/sbf-cpp/Backgrounds.h index 17761dc..72d1118 100644 --- a/sbf-cpp/Backgrounds.h +++ b/sbf-cpp/Backgrounds.h @@ -59,6 +59,10 @@ std::string GetBackgroundLabel(int background_id); /// @brief Fills the provided vector with all valid background labels. /// @param background_labels The vector to fill. It will be emptied first. void FillBackgroundLabels(std::vector& background_labels); + +/// @brief Gets a vector of all the valid background labels. +/// @return The filled vector with index = background_id -1. +std::vector GetBackgroundLabels(); } // End namespace SBF /** @}*/