00001
00009 #if !defined(_AJA_DOCUMENTHEADER_H_)
00010 #define _AJA_DOCUMENTHEADER_H_
00011
00012 #include "aja.h"
00013
00014 namespace aja
00015 {
00016 class ElementItem;
00017
00018
00026 struct transAttr_t
00027 {
00028 dbyte_t attr_id;
00029 std::string attr_name;
00030 std::string attr_desc;
00031 attributeType_t attr_type;
00032 };
00033
00034 typedef std::vector<transAttr_t> transAttr_v;
00035
00036
00044 struct transElm_t
00045 {
00046 number_t elm_id;
00047 std::string elm_name;
00048 std::string elm_desc;
00049 elementType_t elm_type;
00050 transAttr_v attributes;
00051 };
00052
00053 typedef std::vector<transElm_t> transElm_v;
00054
00055
00061 typedef std::map<std::string, std::string> documentValue_v;
00062
00063
00064
00074 class DocumentHeader : public Item
00075 {
00076 public:
00077 DocumentHeader();
00078
00080
00082 public:
00083 byte_t getVersion();
00084 number_t getItemSize();
00085 bool buildAja(OutputBuffer& out);
00086
00087
00088
00089 std::string getValueStr(const char* value_name);
00090 int getValueInt(const char* value_name);
00091 bool setValue(const char* value_name, const std::string& value);
00092 bool setValue(const char* value_name, const char* value);
00093 bool setValue(const char* value_name, const int value);
00094
00095
00096 transElm_t* getTransElement(number_t elm_id);
00097 transElm_t* getTransElement(const char* elm_name);
00098 transAttr_t* getTransAttribute(number_t elm_id, byte_t attr_id);
00099 transAttr_t* getTransAttribute(number_t elm_id, const char* attr_name);
00100 std::string getAttrName(number_t elm_id, byte_t attr_id);
00101 std::string getElmName(number_t elm_id);
00102 bool setTransElement(number_t elm_id, const char* elm_name, elementType_t elm_type = ELM_STRING, const char* elm_desc = "");
00103 bool setTransAttr(number_t elm_id, byte_t attr_id, const char* attr_name, attributeType_t attr_type = ATTR_STRING, const char* attr_desc = "");
00104
00105 static DocumentHeader* parseDocument(const buffer_t buffer, unsigned int size, unsigned int& pos);
00106
00107 private:
00108 static bool processValues(DocumentHeader* header, ElementParent* root);
00109 static bool processTransTable(DocumentHeader* header, ElementParent* table_root);
00110 bool buildValues(ElementParent* root_elm);
00111 bool buildTransTable(ElementParent* root_elm);
00112
00113
00115
00117 private:
00118 documentValue_v mValues;
00119 byte_t mVersion;
00120 transElm_v mTransTable;
00121 };
00122 }
00123
00124 #endif