nat_linden avatar nat_linden committed 42c1f69

Change LLDir::findSkinnedFilenames() to use enum instead of bool.
At Richard's suggestion, changed the bool merge parameter to new enum
ESkinConstraint with values CURRENT_SKIN and ALL_SKINS. This clarifies what
we're requesting at the point of the call.

Comments (0)

Files changed (7)

indra/llui/llnotifications.cpp

 bool LLNotifications::loadTemplates()
 {
 	llinfos << "Reading notifications template" << llendl;
-	// Passing findSkinnedFilenames(merge=true) makes it output all relevant
-	// pathnames instead of just the ones from the most specific skin.
+	// Passing findSkinnedFilenames(constraint=LLDir::ALL_SKINS) makes it
+	// output all relevant pathnames instead of just the ones from the most
+	// specific skin.
 	std::vector<std::string> search_paths =
-		gDirUtilp->findSkinnedFilenames(LLDir::XUI, "notifications.xml", true);
+		gDirUtilp->findSkinnedFilenames(LLDir::XUI, "notifications.xml", LLDir::ALL_SKINS);
 
 	std::string base_filename = search_paths.front();
 	LLXMLNodePtr root;

indra/llui/lltransutil.cpp

 bool LLTransUtil::parseStrings(const std::string& xml_filename, const std::set<std::string>& default_args)
 {
 	// LLUICtrlFactory::getLayeredXMLNode() just calls
-	// gDirUtilp->findSkinnedFilenames(merge=false) and then passes the
-	// resulting paths to LLXMLNode::getLayeredXMLNode(). Bypass that and call
-	// LLXMLNode::getLayeredXMLNode() directly: we want merge=true.
+	// gDirUtilp->findSkinnedFilenames(constraint=LLDir::CURRENT_SKIN) and
+	// then passes the resulting paths to LLXMLNode::getLayeredXMLNode().
+	// Bypass that and call LLXMLNode::getLayeredXMLNode() directly: we want
+	// constraint=LLDir::ALL_SKINS.
 	std::vector<std::string> paths =
-		gDirUtilp->findSkinnedFilenames(LLDir::XUI, xml_filename, true);
+		gDirUtilp->findSkinnedFilenames(LLDir::XUI, xml_filename, LLDir::ALL_SKINS);
 	if (paths.empty())
 	{
 		// xml_filename not found at all in any skin -- check whether entire

indra/llui/lluicolortable.cpp

 {
 	bool result = false;
 
-	// pass merge=true because we want colors.xml from every skin dir
+	// pass constraint=LLDir::ALL_SKINS because we want colors.xml from every
+	// skin dir
 	BOOST_FOREACH(std::string colors_path,
-				  gDirUtilp->findSkinnedFilenames(LLDir::SKINBASE, "colors.xml", true))
+				  gDirUtilp->findSkinnedFilenames(LLDir::SKINBASE, "colors.xml", LLDir::ALL_SKINS))
 	{
 		result |= loadFromFilename(colors_path, mLoadedColors);
 	}

indra/llvfs/lldir.cpp

 #include <boost/range/begin.hpp>
 #include <boost/range/end.hpp>
 #include <algorithm>
-#include <iomanip>
 
 #if LL_WINDOWS
 #include "lldir_win32.h"
 
 std::string LLDir::findSkinnedFilenameBaseLang(const std::string &subdir,
 											   const std::string &filename,
-											   bool merge) const
+											   ESkinConstraint constraint) const
 {
 	// This implementation is basically just as described in the declaration comments.
-	std::vector<std::string> found(findSkinnedFilenames(subdir, filename, merge));
+	std::vector<std::string> found(findSkinnedFilenames(subdir, filename, constraint));
 	if (found.empty())
 	{
 		return "";
 
 std::string LLDir::findSkinnedFilename(const std::string &subdir,
 									   const std::string &filename,
-									   bool merge) const
+									   ESkinConstraint constraint) const
 {
 	// This implementation is basically just as described in the declaration comments.
-	std::vector<std::string> found(findSkinnedFilenames(subdir, filename, merge));
+	std::vector<std::string> found(findSkinnedFilenames(subdir, filename, constraint));
 	if (found.empty())
 	{
 		return "";
 
 std::vector<std::string> LLDir::findSkinnedFilenames(const std::string& subdir,
 													 const std::string& filename,
-													 bool merge) const
+													 ESkinConstraint constraint) const
 {
 	// Recognize subdirs that have no localization.
 	static const char* sUnlocalizedData[] =
 													boost::end(sUnlocalizedData));
 
 	LL_DEBUGS("LLDir") << "subdir '" << subdir << "', filename '" << filename
-					   << "', merge " << std::boolalpha << merge << LL_ENDL;
+					   << "', constraint "
+					   << ((constraint == CURRENT_SKIN)? "CURRENT_SKIN" : "ALL_SKINS")
+					   << LL_ENDL;
 
 	// Cache the default language directory for each subdir we've encountered.
 	// A cache entry whose value is the empty string means "not localized,
 
 		// Here the desired filename exists in the first subsubdir. That means
 		// this is a skindir we want to record in results. But if the caller
-		// passed merge=false, we must discard all previous skindirs.
-		if (! merge)
+		// passed constraint=CURRENT_SKIN, we must discard all previous skindirs.
+		if (constraint == CURRENT_SKIN)
 		{
 			results.clear();
 		}

indra/llvfs/lldir.h

 
 	// these methods search the various skin paths for the specified file in the following order:
 	// getUserSkinDir(), getUserDefaultSkinDir(), getSkinDir(), getDefaultSkinDir()
+	/// param value for findSkinnedFilenames(), explained below
+	enum ESkinConstraint { CURRENT_SKIN, ALL_SKINS };
 	/**
 	 * Given a filename within skin, return an ordered sequence of paths to
 	 * search. Nonexistent files will be filtered out -- which means that the
 	 * level of skin subdirectory).
 	 * @param filename Desired filename within subdir within skin, e.g.
 	 * "panel_login.xml". DO NOT prepend (e.g.) "xui" or the desired language.
-	 * @param merge Callers perform two different kinds of processing. When
-	 * fetching a XUI file, for instance, the existence of @a filename in the
-	 * specified skin completely supercedes any @a filename in the default
-	 * skin. For that case, leave the default @a merge=false. The returned
-	 * vector will contain only
+	 * @param constraint Callers perform two different kinds of processing.
+	 * When fetching a XUI file, for instance, the existence of @a filename in
+	 * the specified skin completely supercedes any @a filename in the default
+	 * skin. For that case, leave the default @a constraint=CURRENT_SKIN. The
+	 * returned vector will contain only
 	 * ".../<i>current_skin</i>/xui/en/<i>filename</i>",
 	 * ".../<i>current_skin</i>/xui/<i>current_language</i>/<i>filename</i>".
 	 * But for (e.g.) "strings.xml", we want a given skin to be able to
 	 * override only specific entries from the default skin. Any string not
 	 * defined in the specified skin will be sought in the default skin. For
-	 * that case, pass @a merge=true. The returned vector will contain at
-	 * least ".../default/xui/en/strings.xml",
+	 * that case, pass @a constraint=ALL_SKINS. The returned vector will
+	 * contain at least ".../default/xui/en/strings.xml",
 	 * ".../default/xui/<i>current_language</i>/strings.xml",
 	 * ".../<i>current_skin</i>/xui/en/strings.xml",
 	 * ".../<i>current_skin</i>/xui/<i>current_language</i>/strings.xml".
 	 */
 	std::vector<std::string> findSkinnedFilenames(const std::string& subdir,
 												  const std::string& filename,
-												  bool merge=false) const;
+												  ESkinConstraint constraint=CURRENT_SKIN) const;
 	/// Values for findSkinnedFilenames(subdir) parameter
 	static const char *XUI, *TEXTURES, *SKINBASE;
 	/**
 	 */
 	std::string findSkinnedFilenameBaseLang(const std::string &subdir,
 											const std::string &filename,
-											bool merge=false) const;
+											ESkinConstraint constraint=CURRENT_SKIN) const;
 	/**
 	 * Return the "most localized" pathname from findSkinnedFilenames(), or
 	 * the empty string if no such file exists. Parameters are identical to
 	 */
 	std::string findSkinnedFilename(const std::string &subdir,
 									const std::string &filename,
-									bool merge=false) const;
+									ESkinConstraint constraint=CURRENT_SKIN) const;
 
 	// random filename in common temporary directory
 	std::string getTempFilename() const;

indra/llvfs/tests/lldir_test.cpp

         ensure_equals(lldir.getLanguage(), "en");
 
         // top-level directory of a skin isn't localized
-        ensure_equals(lldir.findSkinnedFilenames(LLDir::SKINBASE, "colors.xml", true),
+        ensure_equals(lldir.findSkinnedFilenames(LLDir::SKINBASE, "colors.xml", LLDir::ALL_SKINS),
                       vec(list_of("install/skins/default/colors.xml")
                                  ("user/skins/default/colors.xml")));
         // We should not have needed to check for skins/default/en. We should
 
         StringVec expected(vec(list_of("install/skins/default/xui/en/strings.xml")
                                ("user/skins/default/xui/en/strings.xml")));
-        ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", true),
+        ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", LLDir::ALL_SKINS),
                       expected);
         // The first time, we had to probe to find out whether xui was localized.
         lldir.ensure_checked("install/skins/default/xui/en");
         lldir.clear_checked();
         // Now make the same call again -- should return same result --
-        ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", true),
+        ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", LLDir::ALL_SKINS),
                       expected);
         // but this time it should remember that xui is localized.
         lldir.ensure_not_checked("install/skins/default/xui/en");
         ensure_equals(lldir.getLanguage(), "fr");
 
         // pass merge=true to request this filename in all relevant skins
-        ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", true),
+        ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", LLDir::ALL_SKINS),
                       vec(list_of
                           ("install/skins/default/xui/en/strings.xml")
                           ("install/skins/default/xui/fr/strings.xml")
         /*------------------------- "steam", "en" --------------------------*/
         lldir.setSkinFolder("steam", "en");
 
-        ensure_equals(lldir.findSkinnedFilenames(LLDir::SKINBASE, "colors.xml", true),
+        ensure_equals(lldir.findSkinnedFilenames(LLDir::SKINBASE, "colors.xml", LLDir::ALL_SKINS),
                       vec(list_of
                           ("install/skins/default/colors.xml")
                           ("install/skins/steam/colors.xml")
                       vec(list_of("user/skins/steam/xui/en/strings.xml")));
 
         // pass merge=true to request this filename in all relevant skins
-        ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", true),
+        ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", LLDir::ALL_SKINS),
                       vec(list_of
                           ("install/skins/default/xui/en/strings.xml")
                           ("install/skins/steam/xui/en/strings.xml")
                           ("user/skins/steam/xui/fr/strings.xml")));
 
         // pass merge=true to request this filename in all relevant skins
-        ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", true),
+        ensure_equals(lldir.findSkinnedFilenames(LLDir::XUI, "strings.xml", LLDir::ALL_SKINS),
                       vec(list_of
                           ("install/skins/default/xui/en/strings.xml")
                           ("install/skins/default/xui/fr/strings.xml")

indra/newview/llviewertexturelist.cpp

 
 bool LLUIImageList::initFromFile()
 {
-	// Look for textures.xml in all the right places. Pass merge=true because
-	// we want to overlay textures.xml from all the skins directories.
+	// Look for textures.xml in all the right places. Pass
+	// constraint=LLDir::ALL_SKINS because we want to overlay textures.xml
+	// from all the skins directories.
 	std::vector<std::string> textures_paths =
-		gDirUtilp->findSkinnedFilenames(LLDir::TEXTURES, "textures.xml", true);
+		gDirUtilp->findSkinnedFilenames(LLDir::TEXTURES, "textures.xml", LLDir::ALL_SKINS);
 	std::vector<std::string>::const_iterator pi(textures_paths.begin()), pend(textures_paths.end());
 	if (pi == pend)
 	{
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.