aboutsummaryrefslogtreecommitdiffstats
path: root/src/CommandListBuilder.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-04 01:10:48 +0100
committerMax Kellermann <max@duempel.org>2013-01-04 01:16:22 +0100
commit77a99cc61d7a39745192354594086bb90ffb0b50 (patch)
tree20af4a14f4a380a0c54a531aea3380685b2fcf53 /src/CommandListBuilder.hxx
parentfb337418a5b8d85306c96ad51d445fd58fb38491 (diff)
downloadmpd-77a99cc61d7a39745192354594086bb90ffb0b50.tar.gz
mpd-77a99cc61d7a39745192354594086bb90ffb0b50.tar.xz
mpd-77a99cc61d7a39745192354594086bb90ffb0b50.zip
CommandListBuilder: rename attributes
Diffstat (limited to 'src/CommandListBuilder.hxx')
-rw-r--r--src/CommandListBuilder.hxx43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/CommandListBuilder.hxx b/src/CommandListBuilder.hxx
index dbcc15dc2..cc9e7b158 100644
--- a/src/CommandListBuilder.hxx
+++ b/src/CommandListBuilder.hxx
@@ -25,23 +25,38 @@
class CommandListBuilder {
/**
- * for when in list mode
+ * print OK after each command execution
*/
- GSList *cmd_list;
+ enum class Mode {
+ /**
+ * Not active.
+ */
+ DISABLED = -1,
+
+ /**
+ * Enabled in normal list mode.
+ */
+ ENABLED = false,
+
+ /**
+ * Enabled in "list_OK" mode.
+ */
+ OK = true,
+ } mode;
/**
- * print OK after each command execution
+ * for when in list mode
*/
- int cmd_list_OK;
+ GSList *list;
/**
- * mem cmd_list consumes
+ * Memory consumed by the list.
*/
- size_t cmd_list_size;
+ size_t size;
public:
CommandListBuilder()
- :cmd_list(nullptr), cmd_list_OK(-1), cmd_list_size(0) {}
+ :mode(Mode::DISABLED), list(nullptr), size(0) {}
~CommandListBuilder() {
Reset();
}
@@ -50,9 +65,7 @@ public:
* Is a command list currently being built?
*/
bool IsActive() const {
- assert(cmd_list_OK >= -1 && cmd_list_OK <= 1);
-
- return cmd_list_OK >= 0;
+ return mode != Mode::DISABLED;
}
/**
@@ -61,7 +74,7 @@ public:
bool IsOKMode() const {
assert(IsActive());
- return (bool)cmd_list_OK;
+ return (bool)mode;
}
/**
@@ -73,10 +86,10 @@ public:
* Begin building a command list.
*/
void Begin(bool ok) {
- assert(cmd_list == nullptr);
- assert(cmd_list_OK == -1);
+ assert(list == nullptr);
+ assert(mode == Mode::DISABLED);
- cmd_list_OK = (int)ok;
+ mode = (Mode)ok;
}
/**
@@ -93,7 +106,7 @@ public:
/* for scalability reasons, we have prepended each new
command; now we have to reverse it to restore the
correct order */
- return cmd_list = g_slist_reverse(cmd_list);
+ return list = g_slist_reverse(list);
}
};