~ubuntu-branches/debian/sid/pgadmin3/sid

« back to all changes in this revision

Viewing changes to pgadmin/pgscript/utilities/pgsContext.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs
  • Date: 2009-07-30 12:27:16 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730122716-fddbh42on721bbs2
Tags: 1.10.0-1
* New upstream release.
* Adjusted watch file to match release candidates.
* Updated to Standards-Version 3.8.2:
  - Moved to Section: database.
  - Add DEB_BUILD_OPTIONS support for parallel building.
  - Move from findstring to filter suggestion for DEB_BUILD_OPTIONS parsing.
* pgagent got split into its own separate source package by upstream.
* Exclude Docs.vcproj from installation.
* Move doc-base.enus from pgadmin3 to pgadmin3-data package, the files are
  in there too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//////////////////////////////////////////////////////////////////////////
 
2
//
 
3
// pgScript - PostgreSQL Tools
 
4
// RCS-ID:      $Id: pgsContext.cpp 7758 2009-03-26 20:49:59Z dpage $
 
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
 
6
// This software is released under the BSD Licence
 
7
//
 
8
//////////////////////////////////////////////////////////////////////////
 
9
 
 
10
 
 
11
#include "pgAdmin3.h"
 
12
#include "pgscript/utilities/pgsContext.h"
 
13
 
 
14
#include <wx/datetime.h>
 
15
#include <wx/regex.h>
 
16
#include <typeinfo>
 
17
#include "pgscript/objects/pgsNumber.h"
 
18
#include "pgscript/objects/pgsString.h"
 
19
#include "pgscript/statements/pgsExpressionStmt.h"
 
20
 
 
21
#include <wx/listimpl.cpp>
 
22
WX_DEFINE_LIST(pgsListExpression);
 
23
 
 
24
pgsContext::pgsContext(pgsOutputStream & cout) :
 
25
        m_cout(cout)
 
26
{
 
27
        
 
28
}
 
29
 
 
30
pgsContext::~pgsContext()
 
31
{
 
32
        
 
33
}
 
34
 
 
35
pgsVariable * pgsContext::zero()
 
36
{
 
37
        pgsVariable * zero = pnew pgsNumber(wxT("0"));
 
38
        push_var(zero);
 
39
        return zero;
 
40
}
 
41
 
 
42
pgsVariable * pgsContext::one()
 
43
{
 
44
        pgsVariable * one = pnew pgsNumber(wxT("1"));
 
45
        push_var(one);
 
46
        return one;
 
47
}
 
48
 
 
49
pgsVariable * pgsContext::seed()
 
50
{
 
51
        pgsVariable * seed = pnew pgsNumber(wxString() << wxDateTime::GetTimeNow());
 
52
        push_var(seed);
 
53
        return seed;
 
54
}
 
55
 
 
56
pgsVariable * pgsContext::encoding()
 
57
{
 
58
        pgsVariable * encoding = pnew pgsString(wxLocale::GetSystemEncodingName());
 
59
        push_var(encoding);
 
60
        return encoding;
 
61
}
 
62
 
 
63
pgsStmtList * pgsContext::stmt_list(pgsThread * app)
 
64
{
 
65
        pgsStmtList * stmt_list = pnew pgsStmtList(m_cout, app);
 
66
        push_stmt(stmt_list);
 
67
        return stmt_list;
 
68
}
 
69
 
 
70
void pgsContext::add_column(const wxString & column)
 
71
{
 
72
        m_columns.Add(column);
 
73
}
 
74
 
 
75
const wxArrayString & pgsContext::columns()
 
76
{
 
77
        return m_columns;
 
78
}
 
79
 
 
80
void pgsContext::clear_columns()
 
81
{
 
82
        m_columns.Clear();
 
83
}
 
84
 
 
85
void pgsContext::push_var(pgsExpression * var)
 
86
{
 
87
        wxLogScriptVerbose(wxT("PUSH EXPR %s"), var->value().c_str());
 
88
        m_vars.push_back(var);
 
89
}
 
90
 
 
91
void pgsContext::pop_var()
 
92
{
 
93
        wxLogScriptVerbose(wxT("POP EXPR %s"), m_vars.back()->value().c_str());
 
94
        m_vars.pop_back();
 
95
}
 
96
 
 
97
size_t pgsContext::size_vars() const
 
98
{
 
99
        return m_vars.GetCount();
 
100
}
 
101
 
 
102
void pgsContext::push_stmt(pgsStmt * stmt)
 
103
{
 
104
        wxLogScriptVerbose(wxT("PUSH STMT %s"), wxString(typeid(*stmt).name(),
 
105
                        wxConvUTF8).c_str());
 
106
        m_stmts.push_back(stmt);
 
107
}
 
108
 
 
109
void pgsContext::pop_stmt()
 
110
{
 
111
        wxLogScriptVerbose(wxT("POP STMT %s"), wxString(typeid(*(m_stmts.back()))
 
112
                        .name(), wxConvUTF8).c_str());
 
113
        m_stmts.pop_back();
 
114
}
 
115
 
 
116
size_t pgsContext::size_stmts() const
 
117
{
 
118
        return m_stmts.GetCount();
 
119
}
 
120
 
 
121
void pgsContext::clear_stacks()
 
122
{
 
123
        while (!m_vars.empty())
 
124
        {
 
125
                pdelete(m_vars.back());
 
126
                m_vars.pop_back();
 
127
        }
 
128
 
 
129
        while (!m_stmts.empty())
 
130
        {
 
131
                pdelete(m_stmts.back());
 
132
                m_stmts.pop_back();
 
133
        }
 
134
}