Go to the documentation of this file.
25 #ifndef SRC_HEADERS_GX_JSON_H_
26 #define SRC_HEADERS_GX_JSON_H_
30 class GxMachineRemote;
46 virtual const char*
what()
const throw() {
return what_str.c_str(); }
67 JsonWriter(ostream* o = 0,
bool enable_newlines =
true);
75 void write(
float v,
bool nl =
false);
76 void write(
double v,
bool nl =
false);
77 void write(
int i,
bool nl =
false);
78 void write(
unsigned int i,
bool nl =
false);
79 void write(
const char* p,
bool nl =
false);
80 void write(
const string& s,
bool nl =
false) {
write(s.c_str(), nl); }
87 void write_lit(
const string& s,
bool nl =
false);
92 void write_key(
const char* p,
bool nl =
false);
93 void write_key(
const string& p,
bool nl =
false);
116 virtual void close();
147 istringstream b(
str);
153 istringstream b(
str);
158 bool read_kv(
const char *key,
float& v);
159 bool read_kv(
const char *key,
double& v);
160 bool read_kv(
const char *key,
int& i);
161 bool read_kv(
const char *key,
unsigned int& i);
162 bool read_kv(
const char *key, std::string& s);
163 bool read_kv(
const char *key, Glib::ustring& s);
164 template<
class T>
inline bool read_kv(
const char *key, T& v) {
167 v =
static_cast<T
>(i);
328 bool set_factory(
const Glib::ustring& name_,
const std::string& path);
332 void open(
const std::string& fname);
341 const Glib::ustring&
get_name(
int n);
353 bool rename(
const Glib::ustring&
name, Glib::ustring newname);
356 void insert_before(
const Glib::ustring& nm,
const Glib::ustring& newentry);
357 void insert_after(
const Glib::ustring& nm,
const Glib::ustring& newentry);
363 bool set_name(
const Glib::ustring& n,
const std::string& newfile);
429 bl_type::iterator
it;
441 void parse(
const std::string& bank_path,
const std::string&
preset_dir,
442 const std::string& factory_path,
const char* scratchpad_name,
const char* scratchpad_file);
444 int get_index(
const Glib::ustring& bank)
const;
447 bool remove(
const Glib::ustring& bank);
454 bool has_file(
const std::string& file)
const;
455 bool rename(
const Glib::ustring& oldname,
const Glib::ustring& newname,
const std::string& newfile);
456 void reorder(
const std::vector<Glib::ustring>& neworder);
501 bool rename_bank(
const Glib::ustring& oldname,
const Glib::ustring& newname,
const std::string& newfile);
507 #endif // SRC_HEADERS_GX_JSON_H_
void copy_object(JsonWriter &jw)
streampos get_streampos()
void write_kv(const char *key, const char *p)
AbstractPresetIO * preset_io
void save(PresetFile &pf, const Glib::ustring &name)
JsonWriter(ostream *o=0, bool enable_newlines=true)
virtual void read_state(JsonParser &, const SettingsFileHeader &)=0
bool set_name(const Glib::ustring &n, const std::string &newfile)
SettingsFileHeader header
void begin_object(bool nl=false)
void reorder_preset(PresetFile &pf, const std::vector< Glib::ustring > &neworder)
GxSettingsBase(gx_engine::EngineControl &seq_)
bool has_entry(const Glib::ustring &name)
virtual void write_state(JsonWriter &, bool)=0
void parse(const std::string &bank_path, const std::string &preset_dir, const std::string &factory_path, const char *scratchpad_name, const char *scratchpad_file)
void set_io(AbstractStateIO *st, AbstractPresetIO *pr)
void write_kv(const char *key, double v)
bool read_kv(const char *key, T &v)
void parse_factory_list(const std::string &path)
void append(PresetFile &pf, const Glib::ustring &src, PresetFile &pftgt, const Glib::ustring &name)
JsonExceptionEOF(const char *desc)
JsonParser * create_reader()
void insert_after(PresetFile &pf, const Glib::ustring &src, PresetFile &pftgt, const Glib::ustring &pos, const Glib::ustring &name)
sigc::signal< void > selection_changed
int get_index(const Glib::ustring &bank) const
bool remove_bank(const Glib::ustring &bank)
PresetFile * get_file(const Glib::ustring &bank) const
string current_value() const
void erase_preset(const Glib::ustring &name)
void write(float v, bool nl=false)
JsonSubParser(JsonParser &jp, streampos pos)
void set_source_to_state()
string get_filename() const
virtual const char * what() const
const Glib::ustring & get_name() const
bool rename_bank(const Glib::ustring &oldname, const Glib::ustring &newname, const std::string &newfile)
void insert_before(const Glib::ustring &nm, const Glib::ustring &newentry)
std::vector< Position >::iterator iterator
JsonWriter * create_writer_at(const Glib::ustring &pos, const Glib::ustring &name)
void insert_after(const Glib::ustring &nm, const Glib::ustring &newentry)
std::ostream & get_ostream()
bool has_entry(const Glib::ustring &bank) const
virtual void copy_preset(JsonParser &, const SettingsFileHeader &, JsonWriter &)=0
std::list< PresetFile * > bl_type
sigc::signal< void > & signal_selection_changed()
void check_expect(token expect)
sigc::signal< void > & signal_presetlist_changed()
void parse_bank_list(bl_type::iterator pos)
bool convert_preset(PresetFile &pf)
void end_object(bool nl=false)
void append(const Glib::ustring &name)
void set_stream(istream *i)
gx_system::JsonWriter * jw
bool has_file(const std::string &file) const
string readnumber(char c)
void write_null(bool nl=false)
AbstractStateIO * state_io
PresetFile * operator->()
double current_value_double()
sigc::signal< void > presetlist_changed
virtual ~AbstractPresetIO()
virtual ~AbstractStateIO()
bool rename_preset(PresetFile &pf, const Glib::ustring &oldname, const Glib::ustring &newname)
void set_flag(int flag, bool v)
Glib::ustring current_bank
void readJSON_remote(gx_system::JsonParser &jp)
void write_kv(const char *key, float v)
JsonWriter * create_writer(int n)
void throw_unexpected(token expect)
void reorder(const std::vector< Glib::ustring > &neworder)
Position(Glib::ustring n, streampos p)
void insert_before(PresetFile &pf, const Glib::ustring &src, PresetFile &pftgt, const Glib::ustring &pos, const Glib::ustring &name)
static void make_valid_utf8(Glib::ustring &s)
bool open_file(const Glib::ustring &name, const std::string &path, int tp, int flags)
PresetTransformer * create_transformer()
const char * get_token_name(token tok)
const std::string & get_filename() const
bool readJSON(const std::string &dirpath, JsonParser &jp, bool *mtime_diff)
static std::string add_preset_postfix(const std::string &filename)
void make_bank_unique(Glib::ustring &name, std::string *file=0)
void write_kv(const char *key, unsigned int i)
bool read_kv(const char *key, float &v)
void begin_array(bool nl=false)
const SettingsFileHeader & get_header()
void set_stream(ostream *o)
void write(const string &s, bool nl=false)
Glib::ustring current_name
void collect_lost_banks(const char *scratchpad_name, const char *scratchpad_file)
token next(token expect=no_token)
void readJSON_remote(JsonParser &jp)
token read_value_token(char c)
void writeJSON_remote(JsonWriter &jw)
const Glib::ustring & get_current_bank()
const SettingsFileHeader & get_header() const
bool operator!=(const iterator &i) const
unsigned int current_value_uint()
Glib::ustring get_name(int n)
void set_statefilename(const std::string &fn)
virtual void read_preset(JsonParser &, const SettingsFileHeader &)=0
void load_preset(PresetFile *pf, const Glib::ustring &name)
virtual void commit_preset()=0
void save_to_state(bool preserve_preset=false)
bool erase(const Glib::ustring &name)
float current_value_float()
SettingsFileHeader header
JsonWriter * create_writer(bool *preserve_preset)
void write_key(const char *p, bool nl=false)
void set_streampos(streampos pos)
virtual void write_preset(JsonWriter &)=0
bool set_factory(const Glib::ustring &name_, const std::string &path)
JsonParser * create_reader(const Glib::ustring &name)
bool loadsetting(PresetFile *p, const Glib::ustring &name)
PresetFile * get_current_bank_file()
void send_notify_begin(const char *method)
iterator(bl_type::iterator i)
int get_index(const Glib::ustring &name)
const Glib::ustring & get_current_name()
gx_engine::EngineControl & seq
virtual void commit_state()=0
JsonException(const Glib::ustring &desc)
void end_array(bool nl=false)
std::vector< Position > entries
JsonParser * create_reader(int n)
bool remove(const Glib::ustring &bank)
bool create_file(const Glib::ustring &name, const std::string &path, int tp, int flags)
PresetFileGui * get_guiwrapper()
bool rename(const Glib::ustring &oldname, const Glib::ustring &newname, const std::string &newfile)
static bool strip_preset_postfix(std::string &name)
void insert(PresetFile *f, int position=0)
void write_kv(const char *key, const std::string &s)
void write_kv(const char *key, int i)
void write_lit(const string &s, bool nl=false)
void writeJSON(JsonWriter &jw)
void set_filename(const string &fn)
void fill_names(vector< Glib::ustring > &)
bool rename(const Glib::ustring &name, Glib::ustring newname)
@ PRESET_FLAG_VERSIONDIFF