Parcourir la source

added comments and chose better variable name for key (s wtf?)

logicp il y a 5 ans
Parent
commit
734d096a8d
1 fichiers modifiés avec 14 ajouts et 3 suppressions
  1. 14 3
      headers/util.hpp

+ 14 - 3
headers/util.hpp

@@ -75,9 +75,20 @@ static QString escapeTextToRaw(QString s) {
     return escapeText(s).toUtf8().constData();
 }
 
-QString configValue(QString s, ConfigJson config) {
-  if (auto it{config.find(s)}; it != std::end(config)) {
-    return it->second;
+/**
+ * @brief configValue
+ * @param key [in] {QString} The key whose corresponding value is to be sought
+ * from the ConfigJson param
+ * @param [in] {ConfigJson} A Key-Value JSON Config object
+ * @return {QString} The value which corresonds to the key, or an empty string
+ *
+ * TODO: ConfigJson should probably be called something else, like
+ * ConfigJsonObject
+ */
+QString configValue(QString key, ConfigJson config) {
+  ConfigJson::iterator it{config.find(key)};  // Find iterator to element matching key
+  if (it != std::end(config)) {               // If element was found
+    return it->second;                        // Return the value of the Key-Pair element
   }
   return "";
 }