File: pgsContext.h

package info (click to toggle)
pgadmin3 1.20.0~beta2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 73,704 kB
  • ctags: 18,591
  • sloc: cpp: 193,786; ansic: 18,736; sh: 5,154; pascal: 1,120; yacc: 927; makefile: 516; lex: 421; xml: 126; perl: 40
file content (119 lines) | stat: -rw-r--r-- 2,960 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//////////////////////////////////////////////////////////////////////////
//
// pgScript - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////////////////


#ifndef PGSCONTEXT_H_
#define PGSCONTEXT_H_

#include "pgscript/pgScript.h"
#include "pgscript/statements/pgsStmtList.h"

WX_DECLARE_LIST(pgsExpression, pgsListExpression);

class pgsThread;

/** pgsContext is kind of a util class used during script parsing.
 * It is used in pgsParser.yy. Some members are made public because they need
 * to be easily available in order to be passed to some other objects. */
class pgsContext
{

private:

	wxArrayString m_columns;

	/** List of temporary expressions or variables. */
	pgsListExpression m_vars;

	/** List of temporary statements. */
	pgsListStmt m_stmts;

public:

	/** For writing to the output. */
	pgsOutputStream &m_cout;

public:

	//////////////////////////////
	// Constructor & destructor //
	//////////////////////////////

	pgsContext(pgsOutputStream &cout);

	~pgsContext();

	///////////////////////////////
	// Methods generating values //
	///////////////////////////////

	/** Generates a pgsNumber with value '0' and put it on stack. */
	pgsVariable *zero();

	/** Generates a pgsNumber with value '0' and put it on stack. */
	pgsVariable *one();

	/** Generates a pgsNumber with value now() and put it on stack. */
	pgsVariable *seed();

	/** Generates a pgsString with the locale encoding and put it on stack. */
	pgsVariable *encoding();

	/** Generates an empty statement list and put it on stack. */
	pgsStmtList *stmt_list(pgsThread *app = 0);

	////////////////////////////////////////////////
	// For managing a new record declaration list //
	////////////////////////////////////////////////

	/** Adds a column name to the column list. */
	void add_column(const wxString &column);

	/** Retrieves the column list. */
	const wxArrayString &columns();

	/** Clears the column list. */
	void clear_columns();


	/////////////////////////////////////////////
	// For managing stacks of temporary values //
	/////////////////////////////////////////////

	/** Adds a pgsExpression on stack. */
	void push_var(pgsExpression *var);

	/** Removes the last pgsExpression on stack. */
	void pop_var();

	/** Gives the number of pgsExpression on stack. */
	size_t size_vars() const;

	/** Adds a pgsStmt on stack. */
	void push_stmt(pgsStmt *stmt);

	/** Removes the last pgsStmt on stack. */
	void pop_stmt();

	/** Gives the number of pgsStmt on stack. */
	size_t size_stmts() const;

	/** When an error occurs in the parser this method must be called in order
	 * to free the memory (i.e the temporary pgsExpression & pgsStmt). */
	void clear_stacks();

private:

	pgsContext(const pgsContext &that);

	pgsContext &operator=(const pgsContext &that);

};

#endif /*PGSCONTEXT_H_*/