Source Code (Use browser search to find items of interest.)

Class Index

killustrator'XmlAttribute (./koffice/killustrator/xmlutils/XmlElement.h:43)

class XmlAttribute {
public:
  /**
   * Construct an attribute from the given name and value.
   *
   * @param n   The name of the attribute.
   * @param v   The attribute value.
   */
  XmlAttribute (const std::string& n, const std::string& v);

  /**
   * Copy constructor.
   */
  XmlAttribute (const XmlAttribute& attr);

  /**
   * Destructor.
   */
  ~XmlAttribute ();

  /**
   * The assignment operator.
   */
  XmlAttribute& operator= (const XmlAttribute& attr);

  /**
   * Return the name of the attribute.
   *
   * @return The attribute name.
   */
  const std::string& name () const { return aname; }

  /**
   * Return a string representation of the attribute value.
   *
   * @return The attribute value as string.
   */
  const std::string& stringValue () const { return value; }

  /**
   * Return a float representation of the attribute value.
   *
   * @return The attribute value as float.
   */
  float floatValue () const;

  /**
   * Return a integer representation of the attribute value.
   *
   * @return The attribute value as integer.
   */
  int intValue () const;

  /**
   * Return a color representation of the attribute value.
   *
   * @return The attribute value as QColor instance.
   */
  QColor colorValue () const;

  /**
   * Return a matrix representation of the attribute value.
   *
   * @return The attribute value as QWMatrix instance.
   */
  QWMatrix matrixValue () const;

private:
  std::string aname, value;
};

/**
 * An instance of XmlElement represents an element (object) of a XML 
 * document. The elements consists of the tag (element ID) and a list
 * of attributes.
 *
 * @short     A class for representing XML elements.
 * @author    Kai-Uwe Sattler (kus@iti.cs.uni-magdeburg.de)
 * @version   $Id: XmlElement.h,v 1.3 2000/02/08 21:32:49 kulow Exp $
 */

killustrator'XmlAttribute::XmlAttribute() (./koffice/killustrator/xmlutils/XmlElement.cc:31)

XmlAttribute::XmlAttribute (const string& n, const string& v) :
  aname (n), value (v) {
}


killustrator'XmlAttribute::XmlAttribute() (./koffice/killustrator/xmlutils/XmlElement.cc:35)

XmlAttribute::XmlAttribute (const XmlAttribute& attr) : 
  aname (attr.aname), value (attr.value) {
}


killustrator'XmlAttribute::~XmlAttribute() (./koffice/killustrator/xmlutils/XmlElement.cc:39)

XmlAttribute::~XmlAttribute () {
}


killustrator'XmlAttribute::floatValue() (./koffice/killustrator/xmlutils/XmlElement.cc:48)

float XmlAttribute::floatValue () const {
  return atof (value.c_str ());
}


killustrator'XmlAttribute::intValue() (./koffice/killustrator/xmlutils/XmlElement.cc:52)

int XmlAttribute::intValue () const {
  return atoi (value.c_str ());
}


killustrator'XmlAttribute::colorValue() (./koffice/killustrator/xmlutils/XmlElement.cc:56)

QColor XmlAttribute::colorValue () const {
  float red = 0, green = 0, blue = 0;

  istrstream strm (value.c_str ());
  strm >> red >> green >> blue;

  return QColor (red, green, blue);
}


killustrator'XmlAttribute::matrixValue() (./koffice/killustrator/xmlutils/XmlElement.cc:65)

QWMatrix XmlAttribute::matrixValue () const {
  float m11 = 1, m12 = 0, m13 = 0;
  float m21 = 0, m22 = 1, m23 = 0;
  float m31 = 0, m32 = 0, m33 = 1;

  istrstream strm (value.c_str ());
  strm >> m11 >> m12 >> m13 
       >> m21 >> m22 >> m23 
       >> m31 >> m32 >> m33;
  return QWMatrix (m11, m12, m21, m22, m31, m32);
}