Source: OmComment.h


Annotated List
Files
Globals
Hierarchy
Index
#ifndef OM_COMMENT_H
#define OM_COMMENT_H

/**
 * The comment structure.
 *
 * This class provides an implementation of the Comment construction.
 * This corresponds to a zero-terminated C string of 8 bits characters.
 * This is encoded as <!-- representation -->
 */
class OmComment
{
public:
  /**
   * Constructor (can be used as default).
   * @li Precondition: ~ NullPointer(buffer_in)
   */
  explicit OmComment(const char * buffer_in="") {
    OmException::checkNullPointer(buffer_in);
    buffer_ = buffer_in; }

  /**
   * Implement the cloning.
   */
  virtual OmComment * clone() const {
    return new OmComment(*this); }

  /**
   * Destructor.
   */
  virtual ~OmComment() {}

  /**
   * 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; }

  /**
   * Implement the writing to an output device.
   */
  virtual void write(OmOutputDevice & output_in) const {
    output_in.writeComment(buffer_.c_str()); }

  /**
   * Implement the reading from an input device.
   */
  virtual void read(OmInputDevice & input_in) {
    unsigned int length;
    input_in.readLength(length);
    buffer_.resize(length);
    input_in.readComment(&buffer_[0], length); }

protected:
  /**
   * Copy constructor.
   */
  OmComment(const OmComment & other_in)
    : buffer_(other_in.buffer_) {}

private:
  string buffer_;
};

#endif // OM_COMMENT_H

Generated by: root@localhost.localdomain on Tue Oct 12 21:02:30 199.