1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// macros.h - Query SQL macros
//
//////////////////////////////////////////////////////////////////////////
#ifndef MACROS_H
#define MACROS_H
#include <wx/wx.h>
#include <wx/treectrl.h>
#include <libxml/xmlreader.h>
#include <libxml/xmlwriter.h>
class queryMacroItem
{
public:
queryMacroItem(const wxString newKey, const wxString newTitle, const wxString newQuery, const int newId = -1);
wxString GetKey()
{
return key;
};
wxString GetName()
{
return name;
};
wxString GetQuery()
{
return query;
};
int GetId()
{
return id;
};
void AppendToMenu(wxMenu *menu, int newId);
void Update(const wxString &newName, const wxString &newQuery);
protected:
int id;
wxString key, name, query;
};
WX_DEFINE_ARRAY_PTR(queryMacroItem *, queryMacroArray);
class queryMacroList
{
public:
queryMacroList() {};
queryMacroList(xmlTextReaderPtr reader);
int AppendAllToMenu(wxMenu *menu, int startId);
queryMacroItem *FindMacro(int id);
queryMacroItem *FindMacro(const wxString &key);
void AddNewMacro(const wxString &key, const wxString &name, const wxString &query);
void AddOrUpdateMacro(const wxString &key, const wxString &name, const wxString &query);
bool DelMacro(int id);
bool DelMacro(const wxString &key);
void saveList(xmlTextWriterPtr writer);
~queryMacroList();
protected:
queryMacroArray macros;
};
class queryMacroFileProvider
{
public:
static queryMacroList *LoadMacros(bool emptyOnFailure = false);
static void SaveMacros(queryMacroList *macros);
};
#endif /* MACROS_H */
|