libzeep

PrevUpHomeNext

Class attribute

zeep::xml::attribute — An attribute is a node, has an element as parent, but is not a child of this parent (!)

Synopsis

// In header: <zeep/xml/node.hpp>


class attribute : public zeep::xml::node {
public:
  // types
  typedef element parent_type;

  // construct/copy/destruct
  attribute(const attribute &);
  attribute(attribute &&);
  attribute(const std::string &, const std::string &, bool = false);
  attribute & operator=(attribute &&);

  // public member functions
  bool operator==(const attribute &) const;
  bool operator!=(const attribute &) const;
  bool operator<(const attribute &) const;
  virtual std::string get_qname() const;
  virtual void set_qname(const std::string &);
  virtual void set_qname(const std::string &, const std::string &);
  bool is_namespace() const;
  std::string value() const;
  void value(const std::string &);
  std::string uri() const;
  virtual std::string str() const;
  virtual void set_text(const std::string &);
  virtual bool equals(const node *) const;
  virtual bool is_id() const;
  template<size_t N> decltype(auto) get() const;
  void swap(attribute &);
  virtual node * clone() const;
  virtual node * move();

  // protected member functions
  virtual void write(std::ostream &, format_info) const;
};

Description

attribute public construct/copy/destruct

  1. attribute(const attribute & attr);
  2. attribute(attribute && attr);
  3. attribute(const std::string & qname, const std::string & value, 
              bool id = false);
  4. attribute & operator=(attribute && attr);

attribute public member functions

  1. bool operator==(const attribute & a) const;
  2. bool operator!=(const attribute & a) const;
  3. bool operator<(const attribute & ns) const;
  4. virtual std::string get_qname() const;

    Nodes can have a name, and the XPath specification requires that a node can have a so-called expanded-name. This name consists of a local-name and a namespace which is a URI. And we can have a QName which is a concatenation of a prefix (that points to a namespace URI) and a local-name separated by a colon.

    To reduce storage requirements, names are stored in nodes as qnames, if at all.

  5. virtual void set_qname(const std::string & qn);
  6. virtual void set_qname(const std::string & prefix, const std::string & name);
    set the qname with two parameters, if prefix is empty the qname will be simply name otherwise the name will be prefix:name

    Parameters:

    name

    The actual name to use

    prefix

    The namespace prefix to use

  7. bool is_namespace() const;
    Is this attribute an xmlns attribute?
  8. std::string value() const;
  9. void value(const std::string & v);
  10. std::string uri() const;
    same as value, but checks to see if this really is a namespace attribute
  11. virtual std::string str() const;
    return all content concatenated, including that of children.
  12. virtual void set_text(const std::string & value);
    Set text, what really happens depends on the type of the subclass implementing this method.
  13. virtual bool equals(const node * n) const;
    compare nodes for equality
  14. virtual bool is_id() const;
    returns whether this attribute is an ID attribute, as defined in an accompanying DTD
  15. template<size_t N> decltype(auto) get() const;
    support for structured binding
  16. void swap(attribute & a);
  17. virtual node * clone() const;
    return an exact copy of this node, including all data in sub nodes
  18. virtual node * move();

    return a copy of this node, including all data in sub nodes, but in contrast with clone the data is moved from this node to the cloned node. This node will be empty afterwards.

attribute protected member functions

  1. virtual void write(std::ostream & os, format_info fmt) const;
    low level routine for writing out XML

    This method is usually called by operator<<(std::ostream&, zeep::xml::document&)


PrevUpHomeNext