|
|
#ifndef OM_WSTRING_NODE_H #define OM_WSTRING_NODE_H /** * The wstring final node structure. * * This class provides a specialization of OmFinalNode to implement the WString node construction. * This corresponds to a zero-terminated C string of wide characters. * This is encoded as <OMSTR> representation </OMSTR> * The list of children must always be empty. */ class OmWStringNode : public OmFinalNode { public: /** * Constructor (can be used as default). * @li Precondition: ~ NullPointer(buffer_in) */ explicit OmWStringNode(const wchar_t * buffer_in=L"") { OmException::checkNullPointer(buffer_in); buffer_ = buffer_in; } /** * Get the buffer. */ virtual const wchar_t * getBuffer() const { return buffer_.data(); } /** * Set the buffer. * @li Precondition: ~ NullPointer(buffer_in) */ virtual void setBuffer(const wchar_t * buffer_in) { OmException::checkNullPointer(buffer_in); buffer_ = buffer_in; } protected: /** * Copy constructor. */ OmWStringNode(const OmWStringNode & other_in) : OmFinalNode(other_in), buffer_(other_in.buffer_) {} /** * Destructor. */ virtual ~OmWStringNode() {} /** * Implement access to the concrete type. */ virtual OmType typeImp() const { return OmWStringType; } /** * Implement the deep cloning. */ virtual OmNode * cloneImp() const { return new OmWStringNode(*this); } /** * Implement the writing to an output device. */ virtual void writeImp(OmOutputDevice & output_in) const { OmException::checkMalformedNode(buffer_.empty(), "OmWStringNode cannot be empty"); output_in.writeWString(buffer_.data()); } /** * Implement the reading from an input device. */ virtual void readImp(OmInputDevice & input_in) { unsigned int length; input_in.readLength(length); buffer_.resize(length); input_in.readWString(&buffer_[0], length); } private: typedef std::basic_string<wchar_t> wstring_t; wstring_t buffer_; }; #endif // OM_WSTRING_NODE_H
Generated by: root@localhost.localdomain on Tue Oct 12 21:02:30 199. |