// file: $isip/class/mmedia/XMLToken/XMLToken.h // version: $Id: XMLToken.h 10636 2007-01-26 22:18:09Z tm334 $ // make sure definitions are only made once // #ifndef ISIP_XMLTOKEN #define ISIP_XMLTOKEN // isip included files // #ifndef ISIP_VECTOR #include #endif #ifndef ISIP_PAIR #include #endif #ifndef ISIP_STRING #include #endif #ifndef ISIP_SOF #include #endif #ifndef ISIP_DEBUGLEVEL #include #endif // XMLToken: a class to store a single XML tag and information pertaining // to the tag // class XMLToken { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //--------------------------------------- // // other important constants // //--------------------------------------- // define token types // enum TYPE { NULL_TAG = 0, START_TAG, END_TAG, CDATA, START_AND_END_TAG, UNHANDLED, DEF_TYPE = NULL_TAG }; //---------------------------------------- // // error codes // //---------------------------------------- // error codes // static const int32 ERR = 50900; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // A String to store the name of the tag. In the case of CData, // this name tag will store the character data itself. // String value_d; // The type of the tag: START_TAG, END_TAG, or CDATA // TYPE type_d; // a short int to store the depth of the token in the document // to which this token belongs // short int depth_d; // a Vector of Attribute, Value pairs // Vector< Pair > attributes_d; // the debug level // DebugLevel debug_level_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } // method: diagnose // static bool8 diagnose(Integral::DEBUG level); // method: default constructor // XMLToken() { clear(Integral::RESET); } // method: debug // bool8 debug(const unichar* msg) const; // method: assign // bool8 assign(const XMLToken& token); // method: operator= // XMLToken& operator=(const XMLToken& token) { assign(token); return *this; } // method: clear // bool8 clear(Integral::CMODE ctype); // method: read // bool8 read(Sof& sof, int32 tag, const String& cname = CLASS_NAME) { return Error::handle(name(), L"read", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: write // bool8 write(Sof& sof, int32 tag, const String& cname = CLASS_NAME) const { return Error::handle(name(), L"write", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: eq // bool8 eq(const XMLToken& xt) const; // method: operator== // bool8 operator==(const XMLToken& xt) const { return eq(xt); } //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- public: //-------------------------------------------------------- // // get/set methods // //-------------------------------------------------------- // method: setDepth // bool8 setDepth(short int depth); // method: getDepth // int32 getDepth() const { return depth_d; } // method: setValue // bool8 setValue(String value) { return value_d.assign(value); } // method: getValue // String getValue() const{ return value_d; } // method: setType // bool8 setType(TYPE type) { type_d = type; return true; } // method: getType // TYPE getType() const{ return type_d; } // method: setDebug // bool8 setDebug(Integral::DEBUG level) { debug_level_d = level; return true; } // method: getDebug // DebugLevel getDebug() const { return debug_level_d; } // method: setAttributes // bool8 setAttributes(Vector >& attribs) { return attributes_d.assign(attribs); } // method: setAttributes // bool8 setAttributes(const byte8** attrib_array); // method: getAttributes // Vector< Pair > getAttributes() { return attributes_d; } //-------------------------------------------------------- // // attribute manipulation methods // //-------------------------------------------------------- // method: addAttribute // bool8 addAttribute(String attrib_name, String attrib_value); // method: removeAttribute // bool8 removeAttribute(String attrib_name); // method: setAttributeValue // bool8 setAttributeValue(const String aname, const String avalue) { removeAttribute(aname); return addAttribute(aname, avalue); } // method: getAttributeValue // String getAttributeValue(const String arg_name) const; // method: getPointerToValue // String* getPointerToValue() { return &value_d; } //-------------------------------------------------------- // // initialization methods // //-------------------------------------------------------- // method: init // bool8 init(TYPE type, String value, Vector< Pair > attrib_array, int32 token_depth = 0, Integral::CMODE ctype = Integral::RESET); // method: init // bool8 init(TYPE type, String value, int32 token_depth = 0, Integral::CMODE ctype = Integral::RESET); // method: init // bool8 init(TYPE type, String value, const byte8** attrib_array, int32 token_depth = 0, Integral::CMODE ctype = Integral::RESET); //-------------------------------------------------------- // // comparison methods // //-------------------------------------------------------- // method: isA // bool8 isA(XMLToken::TYPE type); // method: isA // bool8 isA(String value); // method: isA // bool8 isA(String value, TYPE type); //-------------------------------------------------------- // // miscellaneous methods // //-------------------------------------------------------- // method: toXML // String toXML() const; // method: hasAttributes // bool8 hasAttributes() { return (attributes_d.length() != 0); } //--------------------------------------------------------------------------- // // protected methods // //--------------------------------------------------------------------------- protected: // method: addQuotes // String addQuotes(String attrib) const; // method: concatAttributesAsXML // bool8 concatAttributesAsXML(String& output) const; }; #endif