mirror of
https://github.com/izzy2lost/ppsspp.git
synced 2026-03-10 12:43:04 -07:00
Listable, json tweaks
This commit is contained in:
@@ -33,7 +33,7 @@ struct Clip {
|
||||
|
||||
// If current_clip == 0, the channel is free.
|
||||
|
||||
enum PlaybackState {
|
||||
enum ClipPlaybackState {
|
||||
PB_STOPPED = 0,
|
||||
PB_PLAYING = 1,
|
||||
};
|
||||
@@ -42,7 +42,7 @@ enum PlaybackState {
|
||||
struct Channel {
|
||||
const Clip *current_clip;
|
||||
// Playback state
|
||||
PlaybackState state;
|
||||
ClipPlaybackState state;
|
||||
int pos;
|
||||
PlayParams params;
|
||||
// Effect state
|
||||
|
||||
@@ -9,19 +9,30 @@ public:
|
||||
virtual ~Listable() {}
|
||||
virtual const char *getItem(size_t i) const = 0;
|
||||
virtual size_t numItems() const = 0;
|
||||
|
||||
// Returns -1 for not found.
|
||||
// Child classes are meant to specialize this if they have a faster way
|
||||
// than brute force search.
|
||||
virtual int getIndex(const char *text) {
|
||||
for (size_t i = 0; i < numItems(); i++) {
|
||||
if (!strcmp(getItem(i), text))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
class ArrayListable : public Listable
|
||||
{
|
||||
public:
|
||||
ArrayListable(const char **arr, size_t count) : arr_(arr), count_(count) {}
|
||||
ArrayListable(const char * const*arr, size_t count) : arr_(arr), count_(count) {}
|
||||
virtual ~ArrayListable() {}
|
||||
|
||||
virtual const char *getItem(size_t i) const { return arr_[i]; }
|
||||
virtual size_t numItems() const { return count_; }
|
||||
|
||||
private:
|
||||
const char **arr_;
|
||||
const char *const*arr_;
|
||||
size_t count_;
|
||||
};
|
||||
|
||||
|
||||
@@ -57,6 +57,10 @@ struct json_value
|
||||
bool getBool(const char *child_name) const;
|
||||
bool getBool(const char *child_name, bool default_value) const;
|
||||
|
||||
bool hasChild(const char *child_name, json_type child_type) const {
|
||||
return get(child_name, child_type) != 0;
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(json_value);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user