00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef fab_h
00024 #define fab_h
00025
00026 #ifndef _REENTRANT
00027 #define _REENTRANT
00028 #endif
00029
00030 #include "config.h"
00031 #include "log.h"
00032 #include <nxml.h>
00033
00034 namespace karoo {
00035
00036 enum fab_status {
00037 FAB_STATUS_UNINITIALISED,
00038 FAB_STATUS_ERROR,
00039 FAB_STATUS_OK
00040 };
00041
00042 class fab {
00043 private:
00044 log logger;
00045 void nxml_set_doc(nxml_data_t* node);
00046
00047 protected:
00048 enum fab_status status;
00049 nxml_t* nxml;
00050 nxml_data_t *root;
00051
00052 bool check(const char* msg, nxml_error_t err) const;
00053 public:
00054 fab();
00055 fab(const text& url);
00056 virtual ~fab();
00057
00062 void setLogger(const log& logger);
00063
00064 nxml_data_t* getRoot() { return root; }
00065 nxml_t* getNXML() { return nxml; }
00066
00067 enum fab_status getStatus() const { return status; }
00068
00069 nxml_data_t* findElement(nxml_data_t* node, const char* name);
00070 nxml_data_t* findElement(nxml_data_t* node, const text& name);
00071 nxml_data_t* findElement(nxml_data_t* node, const text& name, const text& id);
00072 nxml_data_t* findElement(nxml_data_t* node, const char* name, const char* id);
00073 nxml_attr_t* findAttribute(nxml_data_t* node, const char* name);
00074 nxml_attr_t* findAttribute(nxml_data_t* node, const text& name);
00075 nxml_data_t* getFirstChild(nxml_data_t* node) { return node->children; }
00076 nxml_attr_t* getFirstAttribute(nxml_data_t* node) { return node->attributes; }
00077 text getString(nxml_data_t* node) const;
00078 void removeAttribute(nxml_data_t* node, const char* name);
00079 void removeAttribute(nxml_data_t* node, const text& name);
00080 void setAttribute(nxml_data_t* node, const char* name, const char* value);
00081 void setAttribute(nxml_data_t* node, const text& name, const text& value);
00082 void remove(nxml_data_t* node);
00083 nxml_data_t* appendChild(nxml_data_t* node, nxml_data_t* parent);
00084 nxml_data_t* insertAfter(nxml_data_t* node, nxml_data_t* after);
00085 nxml_data_t* insertBefore(nxml_data_t* node, nxml_data_t* before);
00086 nxml_data_t* insertChild(nxml_data_t* node, nxml_data_t* parent);
00087 nxml_data_t* reverseOrder(nxml_data_t* list);
00088 nxml_data_t* replace(nxml_data_t* node, nxml_data_t* before);
00089 nxml_data_t* clone(nxml_data_t* node, bool traverse = true);
00090 int getLine() const;
00091 text toString(nxml_data_t* node) const;
00092 };
00093 }
00094
00095 #endif