Make FileLayout_XXX elements of an enum

Slight improvement to the previous commit: make FileLayout_Classic and
FileLayout_XDG elements of an enum instead of using an untyped "int" for them
which didn't really make any sense because these values are not bit masks but
exclusive choices for the layout.

Also rewrite the checks for them to use "switch" instead of "if" to be warned
by the compiler if we ever add another enum value but forget to update the
code to handle it.

Finally, improve the documentation (add missing "@since") and comments.
This commit is contained in:
Vadim Zeitlin
2017-03-09 17:23:20 +01:00
parent d56d127d3f
commit 4bf6ae8d7c
4 changed files with 160 additions and 95 deletions

View File

@@ -60,10 +60,11 @@ public:
Dir_Videos
};
enum
// Layout to use for user config/data files under Unix.
enum FileLayout
{
FileLayout_Classic = 0,
FileLayout_XDG = 1
FileLayout_Classic, // Default: use home directory.
FileLayout_XDG // Recommended: use XDG specification.
};
// return the global standard paths object
@@ -174,14 +175,14 @@ public:
bool UsesAppInfo(int info) const { return (m_usedAppInfo & info) != 0; }
void SetFileLayout(int layout)
void SetFileLayout(FileLayout layout)
{
m_usedFileLayout = layout;
m_fileLayout = layout;
}
int GetFileLayout() const
FileLayout GetFileLayout() const
{
return m_usedFileLayout;
return m_fileLayout;
}
protected:
@@ -199,7 +200,9 @@ protected:
// combination of AppInfo_XXX flags used by AppendAppInfo()
int m_usedAppInfo;
int m_usedFileLayout;
// The file layout to use, currently only used under Unix.
FileLayout m_fileLayout;
};
#if wxUSE_STDPATHS