|
|
#ifndef OM_STRING_NODE_H #define OM_STRING_NODE_H /** * The string final node structure. * * This class provides a specialization of OmFinalNode to implement the String node construction. * This corresponds to a zero-terminated C string of 8 bits characters. * This is encoded as <OMSTR> representation </OMSTR> * The list of children must always be empty. */ class OmStringNode : public OmFinalNode { public: /** * Constructor (can be used as default). * @li Precondition: ~ NullPointer(buffer_in) */ explicit OmStringNode(const char * buffer_in="") { OmException::checkNullPointer(buffer_in); buffer_ = buffer_in; } /** * Get the buffer. */ virtual const char * getBuffer() const { return buffer_.c_str(); } /** * Set the buffer. * @li Precondition: ~ NullPointer(buffer_in) */ virtual void setBuffer(const char * buffer_in) { OmException::checkNullPointer(buffer_in); buffer_ = buffer_in; } protected: /** * Copy constructor. */ OmStringNode(const OmStringNode & other_in) : OmFinalNode(other_in), buffer_(other_in.buffer_) {} /** * Destructor. */ virtual ~OmStringNode() {} /** * Implement access to the concrete type. */ virtual OmType typeImp() const { return OmStringType; } /** * Implement the deep cloning. */ virtual OmNode * cloneImp() const { return new OmStringNode(*this); } /** * Implement the writing to an output device. */ virtual void writeImp(OmOutputDevice & output_in) const { OmException::checkMalformedNode(buffer_.empty(), "OmStringNode cannot be empty"); output_in.writeString(buffer_.c_str()); } /** * 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.readString(&buffer_[0], length); } private: string buffer_; }; #endif // OM_STRING_NODE_H
Generated by: root@localhost.localdomain on Tue Oct 12 21:02:30 199. |