libzeep

PrevUpHomeNext

Class scope

zeep::http::scope — The class that stores variables for the current scope.

Synopsis

// In header: <zeep/http/el-processing.hpp>


class scope {
public:
  // types
  typedef std::vector< std::unique_ptr< xml::node > > node_set_type;

  // construct/copy/destruct
  scope();
  scope(const request &);
  scope(const server &, const request &);
  explicit scope(const scope &);
  scope & operator=(const scope &);

  // public member functions
  template<typename T> void put(const std::string &, const T &);
  template<typename ForwardIterator> 
    void put(const std::string &, ForwardIterator, ForwardIterator);
  const object & lookup(const std::string &, bool = false) const;
  const object & operator[](const std::string &) const;
  object & lookup(const std::string &);
  object & operator[](const std::string &);
  const request & get_request() const;
  std::string get_context_name() const;
  json::element get_credentials() const;
  void select_object(const object &);
  node_set_type get_nodeset(const std::string &) const;
  void set_nodeset(const std::string &, node_set_type &&);
  bool has_nodeset(const std::string &) const;
  std::string get_csrf_token() const;
  template<> void put(const std::string &, const object &);

  // friend functions
  friend std::ostream & operator<<(std::ostream &, const scope &);
};

Description

When processing tags and in expression language constructs we use variables. These are stored in scope instances.

scope public types

  1. typedef std::vector< std::unique_ptr< xml::node > > node_set_type;

    In tag processors it is sometimes needed to take a selection of zeep::xml::nodes and reuse these, as a copy when inserting templates e.g.

scope public construct/copy/destruct

  1. scope();
    simple constructor, used where there's no request available
  2. scope(const request & req);
    constructor to be used only in debugging

    Parameters:

    req

    The incomming HTTP request

  3. scope(const server & server, const request & req);
    constructor used in a HTTP request context

    Parameters:

    req

    The incomming HTTP request

    server

    The server that handles the incomming request

  4. explicit scope(const scope & next);
    chaining constructor

    Scopes can be nested, introducing new namespaces

    Parameters:

    next

    The next scope up the chain.

  5. scope & operator=(const scope &);

scope public member functions

  1. template<typename T> void put(const std::string & name, const T & value);
    put variable in the scope with name and value
  2. template<typename ForwardIterator> 
      void put(const std::string & name, ForwardIterator begin, 
               ForwardIterator end);
    put variable of type array in the scope with name and values from begin to end
  3. const object & 
    lookup(const std::string & name, bool includeSelected = false) const;
    return variable with name

    Parameters:

    includeSelected

    If this is true, and the variable was not found as a regular variable in the current scope, the selected objects will be search for members with name This is used by the tag processing lib v2 in z2:object

    name

    The name of the variable to return

    Returns:

    The value found or null if there was no such variable.

  4. const object & operator[](const std::string & name) const;
    return variable with name
  5. object & lookup(const std::string & name);
    return variable with name

    Parameters:

    name

    The name of the variable to return

    Returns:

    The value found or null if there was no such variable.

  6. object & operator[](const std::string & name);
    return variable with name
  7. const request & get_request() const;
    return the HTTP request, will throw if the scope chain was not created with a request
  8. std::string get_context_name() const;
    return the context_name of the server
  9. json::element get_credentials() const;
    return the credentials of the current user
  10. void select_object(const object & o);
    select object o , used in z2:object constructs
  11. node_set_type get_nodeset(const std::string & name) const;
    return the node_set_type with name name
  12. void set_nodeset(const std::string & name, node_set_type && nodes);
    store node_set_type nodes with name name
  13. bool has_nodeset(const std::string & name) const;
    return whether a node_set with name name is stored
  14. std::string get_csrf_token() const;
    get the CSRF token from the request burried in scope
  15. template<> void put(const std::string & name, const object & value);

scope friend functions

  1. friend std::ostream & operator<<(std::ostream & lhs, const scope & rhs);
    for debugging purposes

PrevUpHomeNext