[libcamera-devel] [RFC PATCH v2 10/14] libcamera: yaml_parser: Remove memberNames() function

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sat Jun 4 20:59:35 CEST 2022


Now that YamlObject supports iteration, the memberNames() function isn't
useful anymore as it can be implemented using utils::map_keys() if
really needed. Drop it.

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 include/libcamera/internal/yaml_parser.h |  1 -
 src/libcamera/yaml_parser.cpp            | 22 ----------------------
 test/yaml-parser.cpp                     |  9 ---------
 3 files changed, 32 deletions(-)

diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h
index e142cde0fb6f..d0ddb5f682b2 100644
--- a/include/libcamera/internal/yaml_parser.h
+++ b/include/libcamera/internal/yaml_parser.h
@@ -179,7 +179,6 @@ public:
 
 	bool contains(const std::string &key) const;
 	const YamlObject &operator[](const std::string &key) const;
-	std::vector<std::string> memberNames() const;
 
 private:
 	LIBCAMERA_DISABLE_COPY_AND_MOVE(YamlObject)
diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp
index 9cdb370d0f2e..97104ac118a8 100644
--- a/src/libcamera/yaml_parser.cpp
+++ b/src/libcamera/yaml_parser.cpp
@@ -332,28 +332,6 @@ bool YamlObject::contains(const std::string &key) const
 	return true;
 }
 
-/**
- * \fn YamlObject::memberNames()
- * \brief Retrieve all member names of the dictionary
- *
- * This function retrieve member names of a YamlObject. Only YamlObject
- * instances of Dictionary type associate elements with names, calling this
- * function on other types of instances is invalid and results in undefined
- * behaviour.
- *
- * \todo Replace this function with an iterator-based API
- *
- * \return A vector of string as the member names
- */
-std::vector<std::string> YamlObject::memberNames() const
-{
-	std::vector<std::string> memberNames;
-	for (auto &[key, _] : list_)
-		memberNames.push_back(key);
-
-	return memberNames;
-}
-
 /**
  * \fn YamlObject::operator[](const std::string &key) const
  * \brief Retrieve a member by name from the dictionary
diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp
index 6dfec49d6be0..bd92869a4cb3 100644
--- a/test/yaml-parser.cpp
+++ b/test/yaml-parser.cpp
@@ -489,15 +489,6 @@ protected:
 			i++;
 		}
 
-		auto memeberNames = dictObj.memberNames();
-
-		if (memeberNames[0] != "a" ||
-		    memeberNames[1] != "c" ||
-		    memeberNames[2] != "b") {
-			cerr << "Dictionary object fail to parse member names" << std::endl;
-			return TestFail;
-		}
-
 		/* Test leveled objects */
 		auto &level1Obj = (*root)["level1"];
 
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list