summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats
diff options
context:
space:
mode:
author Nathan Woods <npwoods@mess.org>2016-08-27 16:41:11 -0400
committer Nathan Woods <npwoods@mess.org>2016-08-27 16:41:11 -0400
commitb60879e595edc98fb12b7990bd3b45188191bbf1 (patch)
tree9e7a73afa998ca920b407f9c4fd016a2c7c94cdc /src/lib/formats
parent89737886e05e6f9ebc254a47865c3c2335357f1a (diff)
option_guide C++-ification, touched up imgtool
The main point of this change is to C++-ify option_guide. It was changed from a struct array to a class, namespaced etc, with the ultimate hope of incorporating an in-emulation image creation UI. Imgtool got hit with a number of changes; I'll probably have to bring that off of the backburner and touch that up too
Diffstat (limited to 'src/lib/formats')
-rw-r--r--src/lib/formats/flopimg.cpp47
1 files changed, 4 insertions, 43 deletions
diff --git a/src/lib/formats/flopimg.cpp b/src/lib/formats/flopimg.cpp
index 48240973d3a..6ffa7bd6cc2 100644
--- a/src/lib/formats/flopimg.cpp
+++ b/src/lib/formats/flopimg.cpp
@@ -204,35 +204,9 @@ floperr_t floppy_open_choices(void *fp, const struct io_procs *procs, const std:
-static floperr_t option_to_floppy_error(util::option_resolution::error oerr)
-{
- floperr_t err;
- switch(oerr) {
- case util::option_resolution::error::SUCCESS:
- err = FLOPPY_ERROR_SUCCESS;
- break;
- case util::option_resolution::error::OUTOFMEMORY:
- err = FLOPPY_ERROR_OUTOFMEMORY;
- break;
- case util::option_resolution::error::PARAMOUTOFRANGE:
- case util::option_resolution::error::PARAMNOTSPECIFIED:
- case util::option_resolution::error::PARAMNOTFOUND:
- case util::option_resolution::error::PARAMALREADYSPECIFIED:
- case util::option_resolution::error::BADPARAM:
- case util::option_resolution::error::SYNTAX:
- default:
- err = FLOPPY_ERROR_INTERNAL;
- break;
- };
- return err;
-}
-
-
-
floperr_t floppy_create(void *fp, const struct io_procs *procs, const struct FloppyFormat *format, util::option_resolution *parameters, floppy_image_legacy **outfloppy)
{
floppy_image_legacy *floppy = nullptr;
- util::option_resolution::error oerr;
floperr_t err;
int heads, tracks, h, t;
std::unique_ptr<util::option_resolution> alloc_resolution;
@@ -250,26 +224,16 @@ floperr_t floppy_create(void *fp, const struct io_procs *procs, const struct Flo
/* if this format expects creation parameters and none were specified, create some */
if (!parameters && format->param_guidelines)
{
- alloc_resolution = std::make_unique<util::option_resolution>(floppy_option_guide, format->param_guidelines);
+ alloc_resolution = std::make_unique<util::option_resolution>(floppy_option_guide);
if (!alloc_resolution)
{
err = FLOPPY_ERROR_OUTOFMEMORY;
goto done;
}
+ alloc_resolution->set_specification(format->param_guidelines);
parameters = alloc_resolution.get();
}
- /* finish the parameters, if specified */
- if (parameters)
- {
- oerr = parameters->finish();
- if (oerr != util::option_resolution::error::SUCCESS)
- {
- err = option_to_floppy_error(oerr);
- goto done;
- }
- }
-
/* call the format constructor */
err = format->construct(floppy, format, parameters);
if (err)
@@ -690,17 +654,14 @@ floperr_t floppy_format_track(floppy_image_legacy *floppy, int head, int track,
/* create a dummy resolution; if no parameters were specified */
if (!parameters)
{
- alloc_resolution = std::make_unique<util::option_resolution>(floppy_option_guide, floppy->floppy_option->param_guidelines);
+ alloc_resolution = std::make_unique<util::option_resolution>(floppy_option_guide);
if (!alloc_resolution)
return FLOPPY_ERROR_OUTOFMEMORY;
+ alloc_resolution->set_specification(floppy->floppy_option->param_guidelines);
parameters = alloc_resolution.get();
}
- auto oerr = parameters->finish();
- if (oerr != util::option_resolution::error::SUCCESS)
- return option_to_floppy_error(oerr);
-
err = format->format_track(floppy, head, track, parameters);
if (err)
return err;