00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #ifndef _WXP_H_
00014 #define _WXP_H_
00015
00016
00017 #include <wx/xml/xml.h>
00018 #include <wx/wfstream.h>
00019 #include "wxp/package.h"
00020
00021
00022
00023 WX_DECLARE_STRING_HASH_MAP( wxPackageCommandOptionArray,
00024 wxPackageCommandOptionArrayHashMap );
00025
00026
00027 WX_DECLARE_STRING_HASH_MAP( wxPackageCommandSet,
00028 wxPackageCommandSetHashMap );
00029
00030
00031
00032
00033
00034
00037 class wxPackageXML : public wxXmlDocument
00038 {
00039 DECLARE_DYNAMIC_CLASS(wxPackageXML)
00040
00041 public:
00042
00043
00044 wxPackageXML() { m_nIndentationStep=-1; }
00045 virtual ~wxPackageXML() {}
00046
00047
00048 public:
00049
00050 int GetIndentationStep() const
00051 { return m_nIndentationStep; }
00052 void SetIndentationStep(int n)
00053 { m_nIndentationStep=n; }
00054
00055 public:
00056
00058 void HandleUnknownTag(wxXmlNode *node);
00059
00061 wxPackageCommandOptionArray LoadOptions(const wxXmlNode *n);
00062
00064 wxPackageCommandOption LoadOption(const wxXmlNode *n);
00065
00067 wxPackageCondition LoadCondition(const wxXmlNode *n);
00068
00070 wxPackageCommand LoadCommand(const wxXmlNode *n);
00071
00073 wxString GetStrippedNodeContent(const wxXmlNode *n) const;
00074
00075 public:
00076
00080 wxXmlNode *AddChildIndentation(wxXmlNode *node, int level);
00081
00085 wxXmlNode *AddSiblingIndentation(wxXmlNode *node, int level);
00086
00088 wxXmlNode *InsertChildIndentation(wxXmlNode *node, wxXmlNode *before_node, int level);
00089
00090
00091
00092
00093
00094
00096 wxXmlNode *SaveOption(const wxPackageCommandOption &opt, int level);
00097
00099 wxXmlNode *SaveCommand(const wxPackageCommand &cmd, int level);
00100
00102 wxXmlNode *SaveCondition(const wxPackageCondition &cond, int level);
00103
00104 protected:
00105
00107 int m_nIndentationStep;
00108 };
00109
00110
00111
00112
00113
00114
00115
00119 class wxIfNodeListManager
00120 {
00121 public:
00122 wxIfNodeListManager(wxPackageXML *xmldoc, wxXmlNode *parent)
00123 : m_parent(parent), m_doc(xmldoc) { m_previousif=NULL; }
00124
00125 void SmartAppend(wxXmlNode *n, const wxPackageCondition &cnd, int level = 0);
00126 void SaveOptions(const wxPackageCommandOptionArray &arr, int level = 0);
00127 void SaveCommands(const wxPackageCommandArray &arr, int level = 0);
00128
00129
00130 protected:
00131
00132
00133 wxXmlNode *m_parent;
00134
00135
00136 wxPackageXML *m_doc;
00137
00138 protected:
00139
00140
00141
00142 wxXmlNode *m_previousif;
00143
00144
00145
00146 wxPackageCondition m_previouscond;
00147 };
00148
00149
00150
00151
00152
00153
00154
00156 class wxPresetXMLDescriptor : public wxPackageXML
00157 {
00158 DECLARE_DYNAMIC_CLASS(wxPresetXMLDescriptor)
00159
00160 public:
00161 wxPresetXMLDescriptor() {}
00162 virtual ~wxPresetXMLDescriptor() {}
00163
00164
00165 public:
00166
00168 static wxPackageCommandOptionArrayHashMap s_hashmapOptions;
00169
00171 static wxPackageCommandSetHashMap s_hashmapCommands;
00172
00174 static wxArrayString GetCommandPresetNamesFor(wxPackageBuildSystemType type)
00175 {
00176 wxArrayString ret;
00177 wxPackageCommandSetHashMap::const_iterator it;
00178 for ( it = s_hashmapCommands.begin();
00179 it != s_hashmapCommands.end();
00180 it++ )
00181 if (it->second.GetBuildSystemType() == type)
00182 ret.Add(it->first);
00183
00184 return ret;
00185 }
00186
00188 static wxArrayString GetOptionPresetNamesFor(wxPackageBuildSystemType type)
00189 {
00190 wxArrayString ret;
00191 wxPackageCommandOptionArrayHashMap::const_iterator it;
00192 for ( it = s_hashmapOptions.begin();
00193 it != s_hashmapOptions.end();
00194 it++ )
00195 if (it->second.GetCommonCondition().IsValidForBuildSys(type))
00196 ret.Add(it->first);
00197
00198 return ret;
00199 }
00200
00201
00202 #ifdef __WXDEBUG__
00203 static void Dump();
00204 #else
00205 static void Dump() {}
00206 #endif
00207
00208 public:
00209
00212 bool Load(wxInputStream &stream);
00213
00215 static bool Load(const wxString &filename);
00216
00217
00218
00219
00220
00222 bool SavePresets(wxOutputStream &stream);
00223
00225 static bool SavePresets(const wxString &filename);
00226
00227 public:
00228
00230 wxPackageCommandSet LoadCommandSet(const wxXmlNode *n);
00231 };
00232
00233
00234
00235
00236
00237
00240 class wxPackageRepositoryXMLDescriptor : public wxPackageXML
00241 {
00242 DECLARE_DYNAMIC_CLASS(wxPackageRepositoryXMLDescriptor)
00243
00244 public:
00245 wxPackageRepositoryXMLDescriptor() {}
00246 virtual ~wxPackageRepositoryXMLDescriptor() {}
00247
00248
00249 bool Load(const wxString &filename);
00250
00251
00252 bool Load(wxInputStream &stream)
00253 { return wxPackageXML::Load(stream); }
00254
00255 public:
00256
00257 bool AddPackage(const wxString &pkgfile);
00258
00259 public:
00260
00264 wxPackageArray GetPackageArray(const wxString &repourl);
00265 };
00266
00267
00268 #endif // _WXP_H_
00269