<commit_before>/* -*- mode: c++; indent-tabs-mode: nil; tab-width: 2 -*-
 *
 *  $Id: zorba_nodes.h,v 1.1 2006/10/09 07:07:59 <NAME> Exp $
 *
 *	Copyright 2006-2007 FLWOR Foundation.
 *  Author: <NAME>, <NAME>
 *
 */

/*______________________________________________________________________
|
| Includes classes supporting each of the 7 node types defined in:
| XQuery 1.0 and XPath 2.0 Data Model (NODE_TYPES)
| [http://www.w3.org/TR/xpath-datamodel/]
|_______________________________________________________________________*/
 
#ifndef XQP_ZORBA_NODES_H
#define XQP_ZORBA_NODES_H

#include "zorba_qname.h"
#include "nodereps.h"

#include "context/common.h"
#include "values/nodes.h"
#include "runtime/item_iterator.h"
#include "types/sequence_type.h"
#include "values/values.h"
#include "values/qname.h"
#include "util/rchandle.h"

namespace xqp {

class zorba_element_node;
class zorba_attribute_node;
class zorba_namespace_node;


/*______________________________________________________________________
| 6.0 Node
|
|	 1.	Every node must have a unique identity, distinct from all
|	 		other nodes.
|	 2.	The children property of a node must not contain two consecutive
|	 		Text Nodes.
|	 3.	The children property of a node must not contain any empty
|	 		Text Nodes.
|	 4.	The children and attributes properties of a node must not contain
|	 		two nodes with the same identity.
|_______________________________________________________________________*/

class zorba_node : public zorba_item, virtual public node
{
public:		// ctor,dtor
	zorba_node() {}
	virtual ~zorba_node() {}

public:		// internal interface		
	virtual sequence_type_t type() const = 0;
	virtual itemid_t id() const = 0;
	virtual itemid_t parentid() const = 0;
	virtual std::string str(zorba*) const { return ""; }
	virtual std::string get_base_uri(zorba*) const { return ""; };
	virtual std::string get_document_uri(zorba*) const { return ""; };
	virtual std::string get_typed_value(zorba*) const { return ""; };
	virtual const qname* get_node_name(zorba*) const { return 0; }
	virtual const qname* get_type_name(zorba*) const { return 0; }
	virtual const node* get_parent(zorba*) const { return 0; }

public:		// XQuery interface
	virtual iterator_t string_value(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t base_uri(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t document_uri(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t attributes(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t children(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t namespace_nodes(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t node_name(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t parent(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t type_name(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t typed_value(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t atomized_value(zorba*, yy::location &loc) const { return 0; }

	virtual bool is_id() const { return false; }
	virtual bool is_idrefs() const { return false; }
	virtual bool nilled() const { return false; }

public:		// output,serialization
	virtual std::string toXML() const = 0;
	virtual std::ostream& put(zorba*,std::ostream& os) const = 0;
	virtual std::string describe(zorba*) const = 0;

};



class child_iterator : public basic_iterator
{
protected:
	rchandle<child_noderep_iterator> itref;

public:
	child_iterator(const zorba_node&, yy::location &loc);
	~child_iterator() {}

public:
 	void _open();
 	item_t _next();
	void _close();
	bool done() const;


};



class attribute_iterator : public basic_iterator
{
protected:
	rchandle<attribute_noderep_iterator> itref;

public:
	attribute_iterator(const zorba_element_node&, yy::location &loc);
	~attribute_iterator() {}

public:
 	void _open();
 	item_t _next();
	void _close();
	bool done() const;


};


class namespace_iterator : public basic_iterator
{
protected:
	rchandle<namespace_noderep_iterator> itref;

public:
	namespace_iterator(const zorba_element_node&, yy::location &loc);
	~namespace_iterator() {}

public:
 	void _open();
	item_t _next();
	void _close();
	bool done() const;

};



class zorba_document_node : public zorba_node, public document_node
{
protected:<commit_msg>Added _show into the child_iterator, attribute_iterator and namespace_iterator classes.<commit_after>/* -*- mode: c++; indent-tabs-mode: nil; tab-width: 2 -*-
 *
 *  $Id: zorba_nodes.h,v 1.1 2006/10/09 07:07:59 <NAME> Exp $
 *
 *	Copyright 2006-2007 FLWOR Foundation.
 *  Author: <NAME>, <NAME>
 *
 */

/*______________________________________________________________________
|
| Includes classes supporting each of the 7 node types defined in:
| XQuery 1.0 and XPath 2.0 Data Model (NODE_TYPES)
| [http://www.w3.org/TR/xpath-datamodel/]
|_______________________________________________________________________*/
 
#ifndef XQP_ZORBA_NODES_H
#define XQP_ZORBA_NODES_H

#include "zorba_qname.h"
#include "nodereps.h"

#include "context/common.h"
#include "values/nodes.h"
#include "runtime/item_iterator.h"
#include "types/sequence_type.h"
#include "values/values.h"
#include "values/qname.h"
#include "util/rchandle.h"

namespace xqp {

class zorba_element_node;
class zorba_attribute_node;
class zorba_namespace_node;


/*______________________________________________________________________
| 6.0 Node
|
|	 1.	Every node must have a unique identity, distinct from all
|	 		other nodes.
|	 2.	The children property of a node must not contain two consecutive
|	 		Text Nodes.
|	 3.	The children property of a node must not contain any empty
|	 		Text Nodes.
|	 4.	The children and attributes properties of a node must not contain
|	 		two nodes with the same identity.
|_______________________________________________________________________*/

class zorba_node : public zorba_item, virtual public node
{
public:		// ctor,dtor
	zorba_node() {}
	virtual ~zorba_node() {}

public:		// internal interface		
	virtual sequence_type_t type() const = 0;
	virtual itemid_t id() const = 0;
	virtual itemid_t parentid() const = 0;
	virtual std::string str(zorba*) const { return ""; }
	virtual std::string get_base_uri(zorba*) const { return ""; };
	virtual std::string get_document_uri(zorba*) const { return ""; };
	virtual std::string get_typed_value(zorba*) const { return ""; };
	virtual const qname* get_node_name(zorba*) const { return 0; }
	virtual const qname* get_type_name(zorba*) const { return 0; }
	virtual const node* get_parent(zorba*) const { return 0; }

public:		// XQuery interface
	virtual iterator_t string_value(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t base_uri(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t document_uri(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t attributes(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t children(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t namespace_nodes(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t node_name(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t parent(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t type_name(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t typed_value(zorba*, yy::location &loc) const { return 0; }
	virtual iterator_t atomized_value(zorba*, yy::location &loc) const { return 0; }

	virtual bool is_id() const { return false; }
	virtual bool is_idrefs() const { return false; }
	virtual bool nilled() const { return false; }

public:		// output,serialization
	virtual std::string toXML() const = 0;
	virtual std::ostream& put(zorba*,std::ostream& os) const = 0;
	virtual std::string describe(zorba*) const = 0;

};



class child_iterator : public basic_iterator
{
protected:
	rchandle<child_noderep_iterator> itref;

public:
	child_iterator(const zorba_node&, yy::location &loc);
	~child_iterator() {}

public:
 	void _open();
 	item_t _next();
	void _close();
	bool done() const;

	std::ostream&  _show(std::ostream&) const;
};



class attribute_iterator : public basic_iterator
{
protected:
	rchandle<attribute_noderep_iterator> itref;

public:
	attribute_iterator(const zorba_element_node&, yy::location &loc);
	~attribute_iterator() {}

public:
 	void _open();
 	item_t _next();
	void _close();
	bool done() const;

	std::ostream&  _show(std::ostream&) const;
};


class namespace_iterator : public basic_iterator
{
protected:
	rchandle<namespace_noderep_iterator> itref;

public:
	namespace_iterator(const zorba_element_node&, yy::location &loc);
	~namespace_iterator() {}

public:
 	void _open();
	item_t _next();
	void _close();
	bool done() const;

	std::ostream&  _show(std::ostream&) const;
};



class zorba_document_node : public zorba_node, public document_node
{
protected:
{'fraction_non_alphanumeric': 0.11782511210762332, 'fraction_numerical': 0.012780269058295964, 'mean_word_length': 5.3224663359319635, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1028468', 'n_tokens_mistral': 3074, 'n_tokens_neox': 2948, 'n_words': 828}