Converted some more 'enum' to 'enum class'.

This commit is contained in:
Stephen Anthony 2019-04-13 20:57:46 -02:30
parent 0b3fc8890d
commit 53b6a2ef89
6 changed files with 32 additions and 32 deletions

View File

@ -37,21 +37,21 @@ class AbstractFSNode;
class FilesystemNodeFactory
{
public:
enum Type { SYSTEM, ZIP };
enum class Type { SYSTEM, ZIP };
public:
static unique_ptr<AbstractFSNode> create(const string& path, Type type)
{
switch(type)
{
case SYSTEM:
case Type::SYSTEM:
#if defined(BSPF_UNIX) || defined(BSPF_MACOS)
return make_unique<FilesystemNodePOSIX>(path);
#elif defined(BSPF_WINDOWS)
return make_unique<FilesystemNodeWINDOWS>(path);
#endif
break;
case ZIP:
case Type::ZIP:
return make_unique<FilesystemNodeZIP>(path);
break;
}

View File

@ -25,7 +25,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FilesystemNodeZIP::FilesystemNodeZIP()
: _error(ZIPERR_NOT_A_FILE),
: _error(zip_error::NOT_A_FILE),
_numFiles(0),
_isDirectory(false),
_isFile(false)
@ -34,7 +34,7 @@ FilesystemNodeZIP::FilesystemNodeZIP()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FilesystemNodeZIP::FilesystemNodeZIP(const string& p)
: _error(ZIPERR_NONE),
: _error(zip_error::NONE),
_numFiles(0),
_isDirectory(false),
_isFile(false)
@ -55,13 +55,13 @@ FilesystemNodeZIP::FilesystemNodeZIP(const string& p)
{
// TODO: Actually present the error passed in back to the user
// For now, we just indicate that no ROMs were found
_error = ZIPERR_NO_ROMS;
_error = zip_error::NO_ROMS;
return;
}
_numFiles = myZipHandler->romFiles();
if(_numFiles == 0)
{
_error = ZIPERR_NO_ROMS;
_error = zip_error::NO_ROMS;
return;
}
@ -93,7 +93,7 @@ FilesystemNodeZIP::FilesystemNodeZIP(const string& p)
else
_isDirectory = true;
_realNode = FilesystemNodeFactory::create(_zipFile, FilesystemNodeFactory::SYSTEM);
_realNode = FilesystemNodeFactory::create(_zipFile, FilesystemNodeFactory::Type::SYSTEM);
setFlags(_zipFile, _virtualPath, _realNode);
}
@ -102,7 +102,7 @@ FilesystemNodeZIP::FilesystemNodeZIP(const string& p)
FilesystemNodeZIP::FilesystemNodeZIP(
const string& zipfile, const string& virtualpath,
AbstractFSNodePtr realnode, bool isdir)
: _error(ZIPERR_NONE),
: _error(zip_error::NONE),
_numFiles(0),
_isDirectory(isdir),
_isFile(!isdir)
@ -130,11 +130,11 @@ void FilesystemNodeZIP::setFlags(const string& zipfile,
_name = lastPathComponent(_path);
}
_error = ZIPERR_NONE;
_error = zip_error::NONE;
if(!_realNode->isFile())
_error = ZIPERR_NOT_A_FILE;
_error = zip_error::NOT_A_FILE;
if(!_realNode->isReadable())
_error = ZIPERR_NOT_READABLE;
_error = zip_error::NOT_READABLE;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -142,7 +142,7 @@ bool FilesystemNodeZIP::getChildren(AbstractFSList& myList, ListMode mode,
bool hidden) const
{
// Files within ZIP archives don't contain children
if(!isDirectory() || _error != ZIPERR_NONE)
if(!isDirectory() || _error != zip_error::NONE)
return false;
std::set<string> dirs;
@ -181,10 +181,10 @@ uInt32 FilesystemNodeZIP::read(BytePtr& image) const
{
switch(_error)
{
case ZIPERR_NONE: break;
case ZIPERR_NOT_A_FILE: throw runtime_error("ZIP file contains errors/not found");
case ZIPERR_NOT_READABLE: throw runtime_error("ZIP file not readable");
case ZIPERR_NO_ROMS: throw runtime_error("ZIP file doesn't contain any ROMs");
case zip_error::NONE: break;
case zip_error::NOT_A_FILE: throw runtime_error("ZIP file contains errors/not found");
case zip_error::NOT_READABLE: throw runtime_error("ZIP file not readable");
case zip_error::NO_ROMS: throw runtime_error("ZIP file doesn't contain any ROMs");
}
myZipHandler->open(_zipFile);

View File

@ -83,12 +83,12 @@ class FilesystemNodeZIP : public AbstractFSNode
private:
/* Error types */
enum zip_error
enum class zip_error
{
ZIPERR_NONE = 0,
ZIPERR_NOT_A_FILE,
ZIPERR_NOT_READABLE,
ZIPERR_NO_ROMS
NONE,
NOT_A_FILE,
NOT_READABLE,
NO_ROMS
};
AbstractFSNodePtr _realNode;

View File

@ -40,9 +40,9 @@ FilesystemNode::FilesystemNode(const string& p)
{
// Is this potentially a ZIP archive?
if(BSPF::containsIgnoreCase(p, ".zip"))
_realNode = FilesystemNodeFactory::create(p, FilesystemNodeFactory::ZIP);
_realNode = FilesystemNodeFactory::create(p, FilesystemNodeFactory::Type::ZIP);
else
_realNode = FilesystemNodeFactory::create(p, FilesystemNodeFactory::SYSTEM);
_realNode = FilesystemNodeFactory::create(p, FilesystemNodeFactory::Type::SYSTEM);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -67,7 +67,7 @@ HelpDialog::HelpDialog(OSystem& osystem, DialogContainer& parent,
int lwidth = 12 * fontWidth;
xpos += 5; ypos += lineHeight + 4;
for(uInt8 i = 0; i < kLINES_PER_PAGE; ++i)
for(uInt8 i = 0; i < LINES_PER_PAGE; ++i)
{
myKey[i] =
new StaticTextWidget(this, font, xpos, ypos, lwidth,
@ -176,10 +176,10 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
void HelpDialog::displayInfo()
{
string titleStr;
updateStrings(myPage, kLINES_PER_PAGE, titleStr);
updateStrings(myPage, LINES_PER_PAGE, titleStr);
myTitle->setLabel(titleStr);
for(uInt8 i = 0; i < kLINES_PER_PAGE; ++i)
for(uInt8 i = 0; i < LINES_PER_PAGE; ++i)
{
myKey[i]->setLabel(myKeyStr[i]);
myDesc[i]->setLabel(myDescStr[i]);

View File

@ -40,15 +40,15 @@ class HelpDialog : public Dialog
void loadConfig() override { displayInfo(); }
private:
enum { kLINES_PER_PAGE = 10 };
static constexpr uInt32 LINES_PER_PAGE = 10;
ButtonWidget* myNextButton;
ButtonWidget* myPrevButton;
StaticTextWidget* myTitle;
StaticTextWidget* myKey[kLINES_PER_PAGE];
StaticTextWidget* myDesc[kLINES_PER_PAGE];
string myKeyStr[kLINES_PER_PAGE];
string myDescStr[kLINES_PER_PAGE];
StaticTextWidget* myKey[LINES_PER_PAGE];
StaticTextWidget* myDesc[LINES_PER_PAGE];
string myKeyStr[LINES_PER_PAGE];
string myDescStr[LINES_PER_PAGE];
uInt8 myPage;
uInt8 myNumPages;