mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-05-15 14:15:49 -06:00
init
This commit is contained in:
commit
9c6f9f3405
1784 changed files with 440662 additions and 0 deletions
223
include/pgscript/FlexLexer.h
Normal file
223
include/pgscript/FlexLexer.h
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
// -*-C++-*-
|
||||
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
|
||||
// by flex
|
||||
|
||||
// Copyright (c) 1993 The Regents of the University of California.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code is derived from software contributed to Berkeley by
|
||||
// Kent Williams and Tom Epperly.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
|
||||
// Neither the name of the University nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE.
|
||||
|
||||
// This file defines FlexLexer, an abstract class which specifies the
|
||||
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
|
||||
// which defines a particular lexer class.
|
||||
//
|
||||
// If you want to create multiple lexer classes, you use the -P flag
|
||||
// to rename each yyFlexLexer to some other xxFlexLexer. You then
|
||||
// include <FlexLexer.h> in your other sources once per lexer class:
|
||||
//
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer xxFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
//
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer zzFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
// ...
|
||||
|
||||
#ifndef __FLEX_LEXER_H
|
||||
// Never included before - need to define base class.
|
||||
#define __FLEX_LEXER_H
|
||||
|
||||
#include <iostream>
|
||||
# ifndef FLEX_STD
|
||||
# define FLEX_STD std::
|
||||
# endif
|
||||
|
||||
extern "C++"
|
||||
{
|
||||
|
||||
struct yy_buffer_state;
|
||||
typedef int yy_state_type;
|
||||
|
||||
class FlexLexer
|
||||
{
|
||||
public:
|
||||
virtual ~FlexLexer() { }
|
||||
|
||||
const char *YYText()
|
||||
{
|
||||
return yytext;
|
||||
}
|
||||
int YYLeng()
|
||||
{
|
||||
return yyleng;
|
||||
}
|
||||
|
||||
virtual void
|
||||
yy_switch_to_buffer( struct yy_buffer_state * new_buffer ) = 0;
|
||||
virtual struct yy_buffer_state *
|
||||
yy_create_buffer( FLEX_STD istream * s, int size ) = 0;
|
||||
virtual void yy_delete_buffer( struct yy_buffer_state * b ) = 0;
|
||||
virtual void yyrestart( FLEX_STD istream * s ) = 0;
|
||||
|
||||
virtual int yylex() = 0;
|
||||
|
||||
// Call yylex with new input/output sources.
|
||||
int yylex( FLEX_STD istream * new_in, FLEX_STD ostream *new_out = 0 )
|
||||
{
|
||||
switch_streams( new_in, new_out );
|
||||
return yylex();
|
||||
}
|
||||
|
||||
// Switch to new input/output streams. A nil stream pointer
|
||||
// indicates "keep the current one".
|
||||
virtual void switch_streams( FLEX_STD istream *new_in = 0,
|
||||
FLEX_STD ostream *new_out = 0 ) = 0;
|
||||
|
||||
int lineno() const
|
||||
{
|
||||
return yylineno;
|
||||
}
|
||||
|
||||
int debug() const
|
||||
{
|
||||
return yy_flex_debug;
|
||||
}
|
||||
void set_debug( int flag )
|
||||
{
|
||||
yy_flex_debug = flag;
|
||||
}
|
||||
|
||||
protected:
|
||||
char *yytext;
|
||||
int yyleng;
|
||||
int yylineno; // only maintained if you use %option yylineno
|
||||
int yy_flex_debug; // only has effect with -d or "%option debug"
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
|
||||
// Either this is the first time through (yyFlexLexerOnce not defined),
|
||||
// or this is a repeated include to define a different flavor of
|
||||
// yyFlexLexer, as discussed in the flex man page.
|
||||
#define yyFlexLexerOnce
|
||||
|
||||
extern "C++"
|
||||
{
|
||||
|
||||
class yyFlexLexer : public FlexLexer
|
||||
{
|
||||
public:
|
||||
// arg_yyin and arg_yyout default to the cin and cout, but we
|
||||
// only make that assignment when initializing in yylex().
|
||||
yyFlexLexer( FLEX_STD istream *arg_yyin = 0, FLEX_STD ostream *arg_yyout = 0 );
|
||||
|
||||
virtual ~yyFlexLexer();
|
||||
|
||||
void yy_switch_to_buffer( struct yy_buffer_state * new_buffer );
|
||||
struct yy_buffer_state * yy_create_buffer( FLEX_STD istream * s, int size );
|
||||
void yy_delete_buffer( struct yy_buffer_state * b );
|
||||
void yyrestart( FLEX_STD istream * s );
|
||||
|
||||
void yypush_buffer_state( struct yy_buffer_state * new_buffer );
|
||||
void yypop_buffer_state(void);
|
||||
|
||||
virtual int yylex();
|
||||
virtual void switch_streams( FLEX_STD istream * new_in, FLEX_STD ostream * new_out );
|
||||
|
||||
protected:
|
||||
virtual int LexerInput( char *buf, int max_size );
|
||||
virtual void LexerOutput( const char *buf, int size );
|
||||
virtual void LexerError( const char *msg );
|
||||
|
||||
void yyunput( int c, char *buf_ptr );
|
||||
int yyinput();
|
||||
|
||||
void yy_load_buffer_state();
|
||||
void yy_init_buffer( struct yy_buffer_state * b, FLEX_STD istream * s );
|
||||
void yy_flush_buffer( struct yy_buffer_state * b );
|
||||
|
||||
int yy_start_stack_ptr;
|
||||
int yy_start_stack_depth;
|
||||
int *yy_start_stack;
|
||||
|
||||
void yy_push_state( int new_state );
|
||||
void yy_pop_state();
|
||||
int yy_top_state();
|
||||
|
||||
yy_state_type yy_get_previous_state();
|
||||
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
|
||||
int yy_get_next_buffer();
|
||||
|
||||
FLEX_STD istream *yyin; // input source for default LexerInput
|
||||
FLEX_STD ostream *yyout; // output sink for default LexerOutput
|
||||
|
||||
// yy_hold_char holds the character lost when yytext is formed.
|
||||
char yy_hold_char;
|
||||
|
||||
// Number of characters read into yy_ch_buf.
|
||||
int yy_n_chars;
|
||||
|
||||
// Points to current character in buffer.
|
||||
char *yy_c_buf_p;
|
||||
|
||||
int yy_init; // whether we need to initialize
|
||||
int yy_start; // start state number
|
||||
|
||||
// Flag which is used to allow yywrap()'s to do buffer switches
|
||||
// instead of setting up a fresh yyin. A bit of a hack ...
|
||||
int yy_did_buffer_switch_on_eof;
|
||||
|
||||
|
||||
size_t yy_buffer_stack_top; /**< index of top of stack. */
|
||||
size_t yy_buffer_stack_max; /**< capacity of stack. */
|
||||
struct yy_buffer_state **yy_buffer_stack; /**< Stack as an array. */
|
||||
void yyensure_buffer_stack(void);
|
||||
|
||||
// The following are not always needed, but may be depending
|
||||
// on use of certain flex features (like REJECT or yymore()).
|
||||
|
||||
yy_state_type yy_last_accepting_state;
|
||||
char *yy_last_accepting_cpos;
|
||||
|
||||
yy_state_type *yy_state_buf;
|
||||
yy_state_type *yy_state_ptr;
|
||||
|
||||
char *yy_full_match;
|
||||
int *yy_full_state;
|
||||
int yy_full_lp;
|
||||
|
||||
int yy_lp;
|
||||
int yy_looking_for_trail_begin;
|
||||
|
||||
int yy_more_flag;
|
||||
int yy_more_len;
|
||||
int yy_more_offset;
|
||||
int yy_prev_more_offset;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
24
include/pgscript/exceptions/module.mk
Normal file
24
include/pgscript/exceptions/module.mk
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#######################################################################
|
||||
#
|
||||
# pgAdmin III - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
# module.mk - pgadmin/include/pgscript/exceptions/ Makefile fragment
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
pgadmin3_SOURCES += \
|
||||
include/pgscript/exceptions/pgsArithmeticException.h \
|
||||
include/pgscript/exceptions/pgsAssertException.h \
|
||||
include/pgscript/exceptions/pgsBreakException.h \
|
||||
include/pgscript/exceptions/pgsCastException.h \
|
||||
include/pgscript/exceptions/pgsContinueException.h \
|
||||
include/pgscript/exceptions/pgsException.h \
|
||||
include/pgscript/exceptions/pgsInterruptException.h \
|
||||
include/pgscript/exceptions/pgsParameterException.h
|
||||
|
||||
EXTRA_DIST += \
|
||||
include/pgscript/exceptions/module.mk
|
||||
|
||||
35
include/pgscript/exceptions/pgsArithmeticException.h
Normal file
35
include/pgscript/exceptions/pgsArithmeticException.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSARITHMETICEXCEPTION_H_
|
||||
#define PGSARITHMETICEXCEPTION_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/exceptions/pgsException.h"
|
||||
|
||||
class pgsArithmeticException : public pgsException
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
const wxString m_left;
|
||||
const wxString m_right;
|
||||
|
||||
public:
|
||||
|
||||
pgsArithmeticException(const wxString &left, const wxString &right);
|
||||
|
||||
virtual ~pgsArithmeticException();
|
||||
|
||||
virtual const wxString message() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSARITHMETICEXCEPTION_H_*/
|
||||
34
include/pgscript/exceptions/pgsAssertException.h
Normal file
34
include/pgscript/exceptions/pgsAssertException.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSASSERTEXCEPTION_H_
|
||||
#define PGSASSERTEXCEPTION_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/exceptions/pgsException.h"
|
||||
|
||||
class pgsAssertException : public pgsException
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
const wxString m_message;
|
||||
|
||||
public:
|
||||
|
||||
pgsAssertException(const wxString &message);
|
||||
|
||||
virtual ~pgsAssertException();
|
||||
|
||||
virtual const wxString message() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSASSERTEXCEPTION_H_*/
|
||||
30
include/pgscript/exceptions/pgsBreakException.h
Normal file
30
include/pgscript/exceptions/pgsBreakException.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSBREAKEXCEPTION_H_
|
||||
#define PGSBREAKEXCEPTION_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/exceptions/pgsException.h"
|
||||
|
||||
class pgsBreakException : public pgsException
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsBreakException();
|
||||
|
||||
virtual ~pgsBreakException();
|
||||
|
||||
virtual const wxString message() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSBREAKEXCEPTION_H_*/
|
||||
35
include/pgscript/exceptions/pgsCastException.h
Normal file
35
include/pgscript/exceptions/pgsCastException.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSCASTEXCEPTION_H_
|
||||
#define PGSCASTEXCEPTION_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/exceptions/pgsException.h"
|
||||
|
||||
class pgsCastException : public pgsException
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
const wxString m_value;
|
||||
const wxString m_type;
|
||||
|
||||
public:
|
||||
|
||||
pgsCastException(const wxString &value, const wxString &type);
|
||||
|
||||
virtual ~pgsCastException();
|
||||
|
||||
virtual const wxString message() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSCASTEXCEPTION_H_*/
|
||||
30
include/pgscript/exceptions/pgsContinueException.h
Normal file
30
include/pgscript/exceptions/pgsContinueException.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSCONTINUEEXCEPTION_H_
|
||||
#define PGSCONTINUEEXCEPTION_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/exceptions/pgsException.h"
|
||||
|
||||
class pgsContinueException : public pgsException
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsContinueException();
|
||||
|
||||
virtual ~pgsContinueException();
|
||||
|
||||
virtual const wxString message() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSCONTINUEEXCEPTION_H_*/
|
||||
31
include/pgscript/exceptions/pgsException.h
Normal file
31
include/pgscript/exceptions/pgsException.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSEXCEPTION_H_
|
||||
#define PGSEXCEPTION_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
|
||||
class pgsException
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
pgsException();
|
||||
|
||||
public:
|
||||
|
||||
virtual ~pgsException();
|
||||
|
||||
virtual const wxString message() const = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSEXCEPTION_H_*/
|
||||
30
include/pgscript/exceptions/pgsInterruptException.h
Normal file
30
include/pgscript/exceptions/pgsInterruptException.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSINTERRUPTEXCEPTION_H_
|
||||
#define PGSINTERRUPTEXCEPTION_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/exceptions/pgsException.h"
|
||||
|
||||
class pgsInterruptException : public pgsException
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsInterruptException();
|
||||
|
||||
virtual ~pgsInterruptException();
|
||||
|
||||
virtual const wxString message() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSINTERRUPTEXCEPTION_H_*/
|
||||
34
include/pgscript/exceptions/pgsParameterException.h
Normal file
34
include/pgscript/exceptions/pgsParameterException.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSPARAMETEREXCEPTION_H_
|
||||
#define PGSPARAMETEREXCEPTION_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/exceptions/pgsException.h"
|
||||
|
||||
class pgsParameterException : public pgsException
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
const wxString m_message;
|
||||
|
||||
public:
|
||||
|
||||
pgsParameterException(const wxString &message = wxT("unknown"));
|
||||
|
||||
virtual ~pgsParameterException();
|
||||
|
||||
virtual const wxString message() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSPARAMETEREXCEPTION_H_*/
|
||||
54
include/pgscript/expressions/module.mk
Normal file
54
include/pgscript/expressions/module.mk
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#######################################################################
|
||||
#
|
||||
# pgAdmin III - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
# module.mk - pgadmin/include/pgscript/expressions/ Makefile fragment
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
pgadmin3_SOURCES += \
|
||||
include/pgscript/expressions/pgsAnd.h \
|
||||
include/pgscript/expressions/pgsAssign.h \
|
||||
include/pgscript/expressions/pgsAssignToRecord.h \
|
||||
include/pgscript/expressions/pgsCast.h \
|
||||
include/pgscript/expressions/pgsColumns.h \
|
||||
include/pgscript/expressions/pgsDifferent.h \
|
||||
include/pgscript/expressions/pgsEqual.h \
|
||||
include/pgscript/expressions/pgsExecute.h \
|
||||
include/pgscript/expressions/pgsExpression.h \
|
||||
include/pgscript/expressions/pgsExpressions.h \
|
||||
include/pgscript/expressions/pgsGenDate.h \
|
||||
include/pgscript/expressions/pgsGenDateTime.h \
|
||||
include/pgscript/expressions/pgsGenDictionary.h \
|
||||
include/pgscript/expressions/pgsGenInt.h \
|
||||
include/pgscript/expressions/pgsGenReal.h \
|
||||
include/pgscript/expressions/pgsGenReference.h \
|
||||
include/pgscript/expressions/pgsGenRegex.h \
|
||||
include/pgscript/expressions/pgsGenString.h \
|
||||
include/pgscript/expressions/pgsGenTime.h \
|
||||
include/pgscript/expressions/pgsGreater.h \
|
||||
include/pgscript/expressions/pgsGreaterEqual.h \
|
||||
include/pgscript/expressions/pgsIdent.h \
|
||||
include/pgscript/expressions/pgsIdentRecord.h \
|
||||
include/pgscript/expressions/pgsLines.h \
|
||||
include/pgscript/expressions/pgsLower.h \
|
||||
include/pgscript/expressions/pgsLowerEqual.h \
|
||||
include/pgscript/expressions/pgsMinus.h \
|
||||
include/pgscript/expressions/pgsModulo.h \
|
||||
include/pgscript/expressions/pgsNegate.h \
|
||||
include/pgscript/expressions/pgsNot.h \
|
||||
include/pgscript/expressions/pgsOperation.h \
|
||||
include/pgscript/expressions/pgsOr.h \
|
||||
include/pgscript/expressions/pgsOver.h \
|
||||
include/pgscript/expressions/pgsParenthesis.h \
|
||||
include/pgscript/expressions/pgsPlus.h \
|
||||
include/pgscript/expressions/pgsRemoveLine.h \
|
||||
include/pgscript/expressions/pgsTimes.h \
|
||||
include/pgscript/expressions/pgsTrim.h
|
||||
|
||||
EXTRA_DIST += \
|
||||
include/pgscript/expressions/module.mk
|
||||
|
||||
38
include/pgscript/expressions/pgsAnd.h
Normal file
38
include/pgscript/expressions/pgsAnd.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSAND_H_
|
||||
#define PGSAND_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsAnd : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsAnd(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsAnd();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsAnd(const pgsAnd &that);
|
||||
|
||||
pgsAnd &operator =(const pgsAnd &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSAND_H_*/
|
||||
43
include/pgscript/expressions/pgsAssign.h
Normal file
43
include/pgscript/expressions/pgsAssign.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSASSIGN_H_
|
||||
#define PGSASSIGN_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsAssign : public pgsExpression
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
wxString m_name;
|
||||
const pgsExpression *m_var;
|
||||
|
||||
public:
|
||||
|
||||
pgsAssign(const wxString &name, const pgsExpression *var);
|
||||
|
||||
virtual ~pgsAssign();
|
||||
|
||||
pgsAssign(const pgsAssign &that);
|
||||
|
||||
pgsAssign &operator=(const pgsAssign &that);
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSASSIGN_H_*/
|
||||
44
include/pgscript/expressions/pgsAssignToRecord.h
Normal file
44
include/pgscript/expressions/pgsAssignToRecord.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSASSIGNTORECORD_H_
|
||||
#define PGSASSIGNTORECORD_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsAssign.h"
|
||||
|
||||
class pgsAssignToRecord : public pgsAssign
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_line;
|
||||
const pgsExpression *m_column;
|
||||
|
||||
public:
|
||||
|
||||
pgsAssignToRecord(const wxString &name, const pgsExpression *line,
|
||||
const pgsExpression *column, const pgsExpression *var);
|
||||
|
||||
virtual ~pgsAssignToRecord();
|
||||
|
||||
pgsAssignToRecord(const pgsAssignToRecord &that);
|
||||
|
||||
pgsAssignToRecord &operator=(const pgsAssignToRecord &that);
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSASSIGNTORECORD_H_*/
|
||||
46
include/pgscript/expressions/pgsCast.h
Normal file
46
include/pgscript/expressions/pgsCast.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSCAST_H_
|
||||
#define PGSCAST_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsCast : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
int m_cast_type;
|
||||
|
||||
const pgsExpression *m_var;
|
||||
|
||||
public:
|
||||
|
||||
pgsCast(const int &cast_type, const pgsExpression *var);
|
||||
|
||||
virtual ~pgsCast();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsCast(const pgsCast &that);
|
||||
|
||||
pgsCast &operator=(const pgsCast &that);
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSCAST_H_*/
|
||||
42
include/pgscript/expressions/pgsColumns.h
Normal file
42
include/pgscript/expressions/pgsColumns.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSCOLUMNS_H_
|
||||
#define PGSCOLUMNS_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsColumns : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
wxString m_name;
|
||||
|
||||
public:
|
||||
|
||||
pgsColumns(const wxString &name);
|
||||
|
||||
virtual ~pgsColumns();
|
||||
|
||||
/* pgsColumns(const pgsColumns & that); */
|
||||
|
||||
/* pgsColumns & operator=(const pgsColumns & that); */
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSCOLUMNS_H_*/
|
||||
38
include/pgscript/expressions/pgsDifferent.h
Normal file
38
include/pgscript/expressions/pgsDifferent.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSDIFFERENT_H_
|
||||
#define PGSDIFFERENT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsDifferent : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsDifferent(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsDifferent();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsDifferent(const pgsDifferent &that);
|
||||
|
||||
pgsDifferent &operator =(const pgsDifferent &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSDIFFERENT_H_*/
|
||||
43
include/pgscript/expressions/pgsEqual.h
Normal file
43
include/pgscript/expressions/pgsEqual.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSEQUAL_H_
|
||||
#define PGSEQUAL_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsEqual : public pgsOperation
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
bool m_case_sensitive;
|
||||
|
||||
public:
|
||||
|
||||
pgsEqual(const pgsExpression *left, const pgsExpression *right,
|
||||
bool case_sensitive = true);
|
||||
|
||||
virtual ~pgsEqual();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsEqual(const pgsEqual &that);
|
||||
|
||||
pgsEqual &operator =(const pgsEqual &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSEQUAL_H_*/
|
||||
50
include/pgscript/expressions/pgsExecute.h
Normal file
50
include/pgscript/expressions/pgsExecute.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSEXECUTE_H_
|
||||
#define PGSEXECUTE_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsOutputStream;
|
||||
class pgsThread;
|
||||
|
||||
class pgsExecute : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
wxString m_query;
|
||||
|
||||
pgsOutputStream *m_cout;
|
||||
|
||||
pgsThread *m_app;
|
||||
|
||||
public:
|
||||
|
||||
pgsExecute(const wxString &query, pgsOutputStream *cout = 0,
|
||||
pgsThread *app = 0);
|
||||
|
||||
virtual ~pgsExecute();
|
||||
|
||||
/* pgsExecute(const pgsExecute & that); */
|
||||
|
||||
pgsExecute &operator=(const pgsExecute &that);
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSEXECUTE_H_*/
|
||||
48
include/pgscript/expressions/pgsExpression.h
Normal file
48
include/pgscript/expressions/pgsExpression.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSEXPRESSION_H_
|
||||
#define PGSEXPRESSION_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/utilities/pgsCopiedPtr.h"
|
||||
|
||||
class pgsProgram;
|
||||
class pgsVariable;
|
||||
|
||||
WX_DECLARE_STRING_HASH_MAP(pgsCopiedPtr<pgsVariable>, pgsVarMap);
|
||||
typedef pgsCopiedPtr<pgsVariable> pgsOperand;
|
||||
|
||||
class pgsExpression
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
pgsExpression();
|
||||
|
||||
public:
|
||||
|
||||
virtual ~pgsExpression();
|
||||
|
||||
virtual pgsExpression *clone() const = 0;
|
||||
|
||||
/* pgsExpression(const pgsExpression & that); */
|
||||
|
||||
/* pgsExpression & operator =(const pgsExpression & that); */
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const = 0;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSEXPRESSION_H_*/
|
||||
52
include/pgscript/expressions/pgsExpressions.h
Normal file
52
include/pgscript/expressions/pgsExpressions.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSEXPRESSIONS_H_
|
||||
#define PGSEXPRESSIONS_H_
|
||||
|
||||
#include "pgsAnd.h"
|
||||
#include "pgsAssign.h"
|
||||
#include "pgsAssignToRecord.h"
|
||||
#include "pgsCast.h"
|
||||
#include "pgsColumns.h"
|
||||
#include "pgsDifferent.h"
|
||||
#include "pgsEqual.h"
|
||||
#include "pgsExecute.h"
|
||||
#include "pgsExpression.h"
|
||||
#include "pgsGenDate.h"
|
||||
#include "pgsGenDateTime.h"
|
||||
#include "pgsGenDictionary.h"
|
||||
#include "pgsGenInt.h"
|
||||
#include "pgsGenReal.h"
|
||||
#include "pgsGenReference.h"
|
||||
#include "pgsGenRegex.h"
|
||||
#include "pgsGenString.h"
|
||||
#include "pgsGenTime.h"
|
||||
#include "pgsGreater.h"
|
||||
#include "pgsGreaterEqual.h"
|
||||
#include "pgsIdent.h"
|
||||
#include "pgsIdentRecord.h"
|
||||
#include "pgsLines.h"
|
||||
#include "pgsLower.h"
|
||||
#include "pgsLowerEqual.h"
|
||||
#include "pgsMinus.h"
|
||||
#include "pgsModulo.h"
|
||||
#include "pgsNegate.h"
|
||||
#include "pgsNot.h"
|
||||
#include "pgsOperation.h"
|
||||
#include "pgsOr.h"
|
||||
#include "pgsOver.h"
|
||||
#include "pgsParenthesis.h"
|
||||
#include "pgsPlus.h"
|
||||
#include "pgsRemoveLine.h"
|
||||
#include "pgsTimes.h"
|
||||
#include "pgsTrim.h"
|
||||
|
||||
#endif /*PGSEXPRESSIONS_H_*/
|
||||
48
include/pgscript/expressions/pgsGenDate.h
Normal file
48
include/pgscript/expressions/pgsGenDate.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSGENDATE_H_
|
||||
#define PGSGENDATE_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsGenDate : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_min;
|
||||
const pgsExpression *m_max;
|
||||
const pgsExpression *m_sequence;
|
||||
const pgsExpression *m_seed;
|
||||
|
||||
public:
|
||||
|
||||
pgsGenDate(const pgsExpression *min, const pgsExpression *max,
|
||||
const pgsExpression *sequence, const pgsExpression *seed);
|
||||
|
||||
virtual ~pgsGenDate();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsGenDate(const pgsGenDate &that);
|
||||
|
||||
pgsGenDate &operator =(const pgsGenDate &that);
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSGENDATE_H_*/
|
||||
48
include/pgscript/expressions/pgsGenDateTime.h
Normal file
48
include/pgscript/expressions/pgsGenDateTime.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSGENDATETIME_H_
|
||||
#define PGSGENDATETIME_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsGenDateTime : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_min;
|
||||
const pgsExpression *m_max;
|
||||
const pgsExpression *m_sequence;
|
||||
const pgsExpression *m_seed;
|
||||
|
||||
public:
|
||||
|
||||
pgsGenDateTime(const pgsExpression *min, const pgsExpression *max,
|
||||
const pgsExpression *sequence, const pgsExpression *seed);
|
||||
|
||||
virtual ~pgsGenDateTime();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsGenDateTime(const pgsGenDateTime &that);
|
||||
|
||||
pgsGenDateTime &operator =(const pgsGenDateTime &that);
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSGENDATETIME_H_*/
|
||||
49
include/pgscript/expressions/pgsGenDictionary.h
Normal file
49
include/pgscript/expressions/pgsGenDictionary.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSGENDICTIONARY_H_
|
||||
#define PGSGENDICTIONARY_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsGenDictionary : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_file_path;
|
||||
const pgsExpression *m_sequence;
|
||||
const pgsExpression *m_seed;
|
||||
const pgsExpression *m_wx_conv;
|
||||
|
||||
public:
|
||||
|
||||
pgsGenDictionary(const pgsExpression *file_path,
|
||||
const pgsExpression *sequence,
|
||||
const pgsExpression *seed, const pgsExpression *wx_conv);
|
||||
|
||||
virtual ~pgsGenDictionary();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsGenDictionary(const pgsGenDictionary &that);
|
||||
|
||||
pgsGenDictionary &operator =(const pgsGenDictionary &that);
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSGENDICTIONARY_H_*/
|
||||
48
include/pgscript/expressions/pgsGenInt.h
Normal file
48
include/pgscript/expressions/pgsGenInt.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSGENINT_H_
|
||||
#define PGSGENINT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsGenInt : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_min;
|
||||
const pgsExpression *m_max;
|
||||
const pgsExpression *m_sequence;
|
||||
const pgsExpression *m_seed;
|
||||
|
||||
public:
|
||||
|
||||
pgsGenInt(const pgsExpression *min, const pgsExpression *max,
|
||||
const pgsExpression *sequence, const pgsExpression *seed);
|
||||
|
||||
virtual ~pgsGenInt();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsGenInt(const pgsGenInt &that);
|
||||
|
||||
pgsGenInt &operator =(const pgsGenInt &that);
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSGENINT_H_*/
|
||||
50
include/pgscript/expressions/pgsGenReal.h
Normal file
50
include/pgscript/expressions/pgsGenReal.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSGENREAL_H_
|
||||
#define PGSGENREAL_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsGenReal : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_min;
|
||||
const pgsExpression *m_max;
|
||||
const pgsExpression *m_precision;
|
||||
const pgsExpression *m_sequence;
|
||||
const pgsExpression *m_seed;
|
||||
|
||||
public:
|
||||
|
||||
pgsGenReal(const pgsExpression *min, const pgsExpression *max,
|
||||
const pgsExpression *precision,
|
||||
const pgsExpression *sequence, const pgsExpression *seed);
|
||||
|
||||
virtual ~pgsGenReal();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsGenReal(const pgsGenReal &that);
|
||||
|
||||
pgsGenReal &operator =(const pgsGenReal &that);
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSGENREAL_H_*/
|
||||
53
include/pgscript/expressions/pgsGenReference.h
Normal file
53
include/pgscript/expressions/pgsGenReference.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSGENREFERENCE_H_
|
||||
#define PGSGENREFERENCE_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsThread;
|
||||
|
||||
class pgsGenReference : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_table;
|
||||
const pgsExpression *m_column;
|
||||
const pgsExpression *m_sequence;
|
||||
const pgsExpression *m_seed;
|
||||
|
||||
pgsThread *m_app;
|
||||
|
||||
public:
|
||||
|
||||
pgsGenReference(const pgsExpression *table, const pgsExpression *column,
|
||||
const pgsExpression *sequence, const pgsExpression *seed,
|
||||
pgsThread *app = 0);
|
||||
|
||||
virtual ~pgsGenReference();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsGenReference(const pgsGenReference &that);
|
||||
|
||||
pgsGenReference &operator =(const pgsGenReference &that);
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSGENREFERENCE_H_*/
|
||||
45
include/pgscript/expressions/pgsGenRegex.h
Normal file
45
include/pgscript/expressions/pgsGenRegex.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSGENREGEX_H_
|
||||
#define PGSGENREGEX_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsGenRegex : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_regex;
|
||||
const pgsExpression *m_seed;
|
||||
|
||||
public:
|
||||
|
||||
pgsGenRegex(const pgsExpression *regex, const pgsExpression *seed);
|
||||
|
||||
virtual ~pgsGenRegex();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsGenRegex(const pgsGenRegex &that);
|
||||
|
||||
pgsGenRegex &operator =(const pgsGenRegex &that);
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSGENREGEX_H_*/
|
||||
48
include/pgscript/expressions/pgsGenString.h
Normal file
48
include/pgscript/expressions/pgsGenString.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSGENSTRING_H_
|
||||
#define PGSGENSTRING_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsGenString : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_min;
|
||||
const pgsExpression *m_max;
|
||||
const pgsExpression *m_nb_words;
|
||||
const pgsExpression *m_seed;
|
||||
|
||||
public:
|
||||
|
||||
pgsGenString(const pgsExpression *min, const pgsExpression *max,
|
||||
const pgsExpression *nb_words, const pgsExpression *seed);
|
||||
|
||||
virtual ~pgsGenString();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsGenString(const pgsGenString &that);
|
||||
|
||||
pgsGenString &operator =(const pgsGenString &that);
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSGENSTRING_H_*/
|
||||
48
include/pgscript/expressions/pgsGenTime.h
Normal file
48
include/pgscript/expressions/pgsGenTime.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSGENTIME_H_
|
||||
#define PGSGENTIME_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsGenTime : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_min;
|
||||
const pgsExpression *m_max;
|
||||
const pgsExpression *m_sequence;
|
||||
const pgsExpression *m_seed;
|
||||
|
||||
public:
|
||||
|
||||
pgsGenTime(const pgsExpression *min, const pgsExpression *max,
|
||||
const pgsExpression *sequence, const pgsExpression *seed);
|
||||
|
||||
virtual ~pgsGenTime();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsGenTime(const pgsGenTime &that);
|
||||
|
||||
pgsGenTime &operator =(const pgsGenTime &that);
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSGENTIME_H_*/
|
||||
38
include/pgscript/expressions/pgsGreater.h
Normal file
38
include/pgscript/expressions/pgsGreater.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSGREATER_H_
|
||||
#define PGSGREATER_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsGreater : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsGreater(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsGreater();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsGreater(const pgsGreater &that);
|
||||
|
||||
pgsGreater &operator =(const pgsGreater &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSGREATER_H_*/
|
||||
38
include/pgscript/expressions/pgsGreaterEqual.h
Normal file
38
include/pgscript/expressions/pgsGreaterEqual.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSGREATEREQUAL_H_
|
||||
#define PGSGREATEREQUAL_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsGreaterEqual : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsGreaterEqual(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsGreaterEqual();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsGreaterEqual(const pgsGreaterEqual &that);
|
||||
|
||||
pgsGreaterEqual &operator =(const pgsGreaterEqual &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSGREATEREQUAL_H_*/
|
||||
46
include/pgscript/expressions/pgsIdent.h
Normal file
46
include/pgscript/expressions/pgsIdent.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSIDENT_H_
|
||||
#define PGSIDENT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsIdent : public pgsExpression
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
wxString m_name;
|
||||
|
||||
public:
|
||||
|
||||
pgsIdent(const wxString &name);
|
||||
|
||||
virtual ~pgsIdent();
|
||||
|
||||
/* pgsIdent(const pgsIdent & that); */
|
||||
|
||||
/* pgsIdent & operator=(const pgsIdent & that); */
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
public:
|
||||
|
||||
static const wxString m_now;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSIDENT_H_*/
|
||||
44
include/pgscript/expressions/pgsIdentRecord.h
Normal file
44
include/pgscript/expressions/pgsIdentRecord.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSIDENTRECORD_H_
|
||||
#define PGSIDENTRECORD_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsIdent.h"
|
||||
|
||||
class pgsIdentRecord : public pgsIdent
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_line;
|
||||
const pgsExpression *m_column;
|
||||
|
||||
public:
|
||||
|
||||
pgsIdentRecord(const wxString &name, const pgsExpression *line,
|
||||
const pgsExpression *column = 0);
|
||||
|
||||
virtual ~pgsIdentRecord();
|
||||
|
||||
pgsIdentRecord(const pgsIdentRecord &that);
|
||||
|
||||
pgsIdentRecord &operator=(const pgsIdentRecord &that);
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSIDENTRECORD_H_*/
|
||||
42
include/pgscript/expressions/pgsLines.h
Normal file
42
include/pgscript/expressions/pgsLines.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSLINES_H_
|
||||
#define PGSLINES_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsLines : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
wxString m_name;
|
||||
|
||||
public:
|
||||
|
||||
pgsLines(const wxString &name);
|
||||
|
||||
virtual ~pgsLines();
|
||||
|
||||
/* pgsLines(const pgsLines & that); */
|
||||
|
||||
/* pgsLines & operator=(const pgsLines & that); */
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSLINES_H_*/
|
||||
38
include/pgscript/expressions/pgsLower.h
Normal file
38
include/pgscript/expressions/pgsLower.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSLOWER_H_
|
||||
#define PGSLOWER_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsLower : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsLower(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsLower();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsLower(const pgsLower &that);
|
||||
|
||||
pgsLower &operator =(const pgsLower &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSLOWER_H_*/
|
||||
38
include/pgscript/expressions/pgsLowerEqual.h
Normal file
38
include/pgscript/expressions/pgsLowerEqual.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSLOWEREQUAL_H_
|
||||
#define PGSLOWEREQUAL_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsLowerEqual : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsLowerEqual(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsLowerEqual();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsLowerEqual(const pgsLowerEqual &that);
|
||||
|
||||
pgsLowerEqual &operator =(const pgsLowerEqual &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSLOWEREQUAL_H_*/
|
||||
38
include/pgscript/expressions/pgsMinus.h
Normal file
38
include/pgscript/expressions/pgsMinus.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSMINUS_H_
|
||||
#define PGSMINUS_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsMinus : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsMinus(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsMinus();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsMinus(const pgsMinus &that);
|
||||
|
||||
pgsMinus &operator =(const pgsMinus &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSMINUS_H_*/
|
||||
38
include/pgscript/expressions/pgsModulo.h
Normal file
38
include/pgscript/expressions/pgsModulo.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSMODULO_H_
|
||||
#define PGSMODULO_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsModulo : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsModulo(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsModulo();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsModulo(const pgsModulo &that);
|
||||
|
||||
pgsModulo &operator =(const pgsModulo &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSMODULO_H_*/
|
||||
38
include/pgscript/expressions/pgsNegate.h
Normal file
38
include/pgscript/expressions/pgsNegate.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSNEGATE_H_
|
||||
#define PGSNEGATE_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsNegate : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsNegate(const pgsExpression *left);
|
||||
|
||||
virtual ~pgsNegate();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsNegate(const pgsNegate &that);
|
||||
|
||||
pgsNegate &operator =(const pgsNegate &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSNEGATE_H_*/
|
||||
38
include/pgscript/expressions/pgsNot.h
Normal file
38
include/pgscript/expressions/pgsNot.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSNOT_H_
|
||||
#define PGSNOT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsNot : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsNot(const pgsExpression *left);
|
||||
|
||||
virtual ~pgsNot();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsNot(const pgsNot &that);
|
||||
|
||||
pgsNot &operator =(const pgsNot &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSNOT_H_*/
|
||||
43
include/pgscript/expressions/pgsOperation.h
Normal file
43
include/pgscript/expressions/pgsOperation.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSOPERATION_H_
|
||||
#define PGSOPERATION_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsOperation : public pgsExpression
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
const pgsExpression *m_left;
|
||||
const pgsExpression *m_right;
|
||||
|
||||
public:
|
||||
|
||||
pgsOperation(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsOperation();
|
||||
|
||||
virtual pgsExpression *clone() const = 0;
|
||||
|
||||
pgsOperation(const pgsOperation &that);
|
||||
|
||||
pgsOperation &operator =(const pgsOperation &that);
|
||||
|
||||
virtual wxString value() const = 0;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSOPERATION_H_*/
|
||||
38
include/pgscript/expressions/pgsOr.h
Normal file
38
include/pgscript/expressions/pgsOr.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSOR_H_
|
||||
#define PGSOR_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsOr : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsOr(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsOr();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsOr(const pgsOr &that);
|
||||
|
||||
pgsOr &operator =(const pgsOr &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSOR_H_*/
|
||||
38
include/pgscript/expressions/pgsOver.h
Normal file
38
include/pgscript/expressions/pgsOver.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSOVER_H_
|
||||
#define PGSOVER_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsOver : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsOver(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsOver();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsOver(const pgsOver &that);
|
||||
|
||||
pgsOver &operator =(const pgsOver &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSOVER_H_*/
|
||||
38
include/pgscript/expressions/pgsParenthesis.h
Normal file
38
include/pgscript/expressions/pgsParenthesis.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSPARENTHESIS_H_
|
||||
#define PGSPARENTHESIS_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsParenthesis : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsParenthesis(const pgsExpression *left);
|
||||
|
||||
virtual ~pgsParenthesis();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsParenthesis(const pgsParenthesis &that);
|
||||
|
||||
pgsParenthesis &operator =(const pgsParenthesis &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSPARENTHESIS_H_*/
|
||||
38
include/pgscript/expressions/pgsPlus.h
Normal file
38
include/pgscript/expressions/pgsPlus.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSPLUS_H_
|
||||
#define PGSPLUS_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsPlus : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsPlus(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsPlus();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsPlus(const pgsPlus &that);
|
||||
|
||||
pgsPlus &operator =(const pgsPlus &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSPLUS_H_*/
|
||||
43
include/pgscript/expressions/pgsRemoveLine.h
Normal file
43
include/pgscript/expressions/pgsRemoveLine.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSREMOVELINE_H_
|
||||
#define PGSREMOVELINE_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsRemoveLine : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
wxString m_rec;
|
||||
const pgsExpression *m_line;
|
||||
|
||||
public:
|
||||
|
||||
pgsRemoveLine(const wxString &rec, const pgsExpression *line);
|
||||
|
||||
virtual ~pgsRemoveLine();
|
||||
|
||||
pgsRemoveLine(const pgsRemoveLine &that);
|
||||
|
||||
pgsRemoveLine &operator=(const pgsRemoveLine &that);
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSREMOVELINE_H_*/
|
||||
38
include/pgscript/expressions/pgsTimes.h
Normal file
38
include/pgscript/expressions/pgsTimes.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSTIMES_H_
|
||||
#define PGSTIMES_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsOperation.h"
|
||||
|
||||
class pgsTimes : public pgsOperation
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsTimes(const pgsExpression *left, const pgsExpression *right);
|
||||
|
||||
virtual ~pgsTimes();
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
pgsTimes(const pgsTimes &that);
|
||||
|
||||
pgsTimes &operator =(const pgsTimes &that);
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSTIMES_H_*/
|
||||
42
include/pgscript/expressions/pgsTrim.h
Normal file
42
include/pgscript/expressions/pgsTrim.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSTRIM_H_
|
||||
#define PGSTRIM_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsTrim : public pgsExpression
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_exp;
|
||||
|
||||
public:
|
||||
|
||||
pgsTrim(const pgsExpression *exp);
|
||||
|
||||
virtual ~pgsTrim();
|
||||
|
||||
pgsTrim(const pgsTrim &that);
|
||||
|
||||
pgsTrim &operator=(const pgsTrim &that);
|
||||
|
||||
virtual pgsExpression *clone() const;
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSTRIM_H_*/
|
||||
27
include/pgscript/generators/module.mk
Normal file
27
include/pgscript/generators/module.mk
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#######################################################################
|
||||
#
|
||||
# pgAdmin III - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
# module.mk - pgadmin/include/pgscript/generators/ Makefile fragment
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
pgadmin3_SOURCES += \
|
||||
include/pgscript/generators/pgsDateGen.h \
|
||||
include/pgscript/generators/pgsDateTimeGen.h \
|
||||
include/pgscript/generators/pgsDictionaryGen.h \
|
||||
include/pgscript/generators/pgsIntegerGen.h \
|
||||
include/pgscript/generators/pgsNumberGen.h \
|
||||
include/pgscript/generators/pgsObjectGen.h \
|
||||
include/pgscript/generators/pgsRealGen.h \
|
||||
include/pgscript/generators/pgsReferenceGen.h \
|
||||
include/pgscript/generators/pgsRegexGen.h \
|
||||
include/pgscript/generators/pgsStringGen.h \
|
||||
include/pgscript/generators/pgsTimeGen.h
|
||||
|
||||
EXTRA_DIST += \
|
||||
include/pgscript/generators/module.mk
|
||||
|
||||
51
include/pgscript/generators/pgsDateGen.h
Normal file
51
include/pgscript/generators/pgsDateGen.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSDATEGEN_H_
|
||||
#define PGSDATEGEN_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include <wx/datetime.h>
|
||||
#include "pgscript/generators/pgsIntegerGen.h"
|
||||
|
||||
class pgsDateGen : public pgsObjectGen
|
||||
{
|
||||
private:
|
||||
|
||||
typedef pgsCopiedPtr<pgsIntegerGen> pgsRandomizer; // Needs a clone() method
|
||||
|
||||
wxDateTime m_min;
|
||||
wxDateTime m_max;
|
||||
int m_range;
|
||||
|
||||
bool m_sequence;
|
||||
|
||||
pgsRandomizer m_randomizer;
|
||||
|
||||
public:
|
||||
|
||||
pgsDateGen(wxDateTime min, wxDateTime max, const bool &sequence,
|
||||
const long &seed = wxDateTime::GetTimeNow());
|
||||
|
||||
bool is_sequence() const;
|
||||
|
||||
virtual wxString random();
|
||||
|
||||
virtual ~pgsDateGen();
|
||||
|
||||
virtual pgsDateGen *clone();
|
||||
|
||||
/* pgsDateGen & operator =(const pgsDateGen & that); */
|
||||
|
||||
/* pgsDateGen(const pgsDateGen & that); */
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSDATEGEN_H_*/
|
||||
51
include/pgscript/generators/pgsDateTimeGen.h
Normal file
51
include/pgscript/generators/pgsDateTimeGen.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSDATETIMEGEN_H_
|
||||
#define PGSDATETIMEGEN_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include <wx/datetime.h>
|
||||
#include "pgscript/generators/pgsIntegerGen.h"
|
||||
|
||||
class pgsDateTimeGen : public pgsObjectGen
|
||||
{
|
||||
private:
|
||||
|
||||
typedef pgsCopiedPtr<pgsIntegerGen> pgsRandomizer; // Needs a clone() method
|
||||
|
||||
wxDateTime m_min;
|
||||
wxDateTime m_max;
|
||||
wxLongLong m_range;
|
||||
|
||||
bool m_sequence;
|
||||
|
||||
pgsRandomizer m_randomizer;
|
||||
|
||||
public:
|
||||
|
||||
pgsDateTimeGen(wxDateTime min, wxDateTime max, const bool &sequence,
|
||||
const long &seed = wxDateTime::GetTimeNow());
|
||||
|
||||
bool is_sequence() const;
|
||||
|
||||
virtual wxString random();
|
||||
|
||||
virtual ~pgsDateTimeGen();
|
||||
|
||||
virtual pgsDateTimeGen *clone();
|
||||
|
||||
/* pgsDateTimeGen & operator =(const pgsDateTimeGen & that); */
|
||||
|
||||
/* pgsDateTimeGen(const pgsDateTimeGen & that); */
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSDATETIMEGEN_H_*/
|
||||
58
include/pgscript/generators/pgsDictionaryGen.h
Normal file
58
include/pgscript/generators/pgsDictionaryGen.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSDICTIONARYGEN_H_
|
||||
#define PGSDICTIONARYGEN_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/generators/pgsIntegerGen.h"
|
||||
|
||||
class pgsDictionaryGen : public pgsObjectGen
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
typedef pgsCopiedPtr<pgsIntegerGen> pgsRandomizer; // Needs a clone() method
|
||||
|
||||
wxString m_file_path;
|
||||
wxCSConv m_conv;
|
||||
|
||||
long m_nb_lines;
|
||||
|
||||
pgsRandomizer m_randomizer;
|
||||
|
||||
public:
|
||||
|
||||
pgsDictionaryGen(const wxString &file_path, const bool &sequence = false,
|
||||
const long &seed = wxDateTime::GetTimeNow(), wxCSConv conv = wxConvLocal);
|
||||
|
||||
virtual wxString random();
|
||||
|
||||
virtual ~pgsDictionaryGen();
|
||||
|
||||
virtual pgsDictionaryGen *clone();
|
||||
|
||||
/* pgsDictionaryGen(const pgsDictionaryGen & that); */
|
||||
|
||||
const long &nb_lines() const;
|
||||
|
||||
private:
|
||||
|
||||
pgsDictionaryGen &operator =(const pgsDictionaryGen &that);
|
||||
|
||||
private:
|
||||
|
||||
long count_lines();
|
||||
|
||||
wxString get_line(long line_nb);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSDICTIONARYGEN_H_*/
|
||||
115
include/pgscript/generators/pgsIntegerGen.h
Normal file
115
include/pgscript/generators/pgsIntegerGen.h
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSINTEGERGEN_H_
|
||||
#define PGSINTEGERGEN_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/generators/pgsNumberGen.h"
|
||||
#include "pgscript/generators/pgsObjectGen.h"
|
||||
#include "pgscript/utilities/pgsCopiedPtr.h"
|
||||
|
||||
class pgsIntegerGen : public pgsObjectGen
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
class pgsSequentialIntGen : public pgsNumberGen
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
MAPM m_state;
|
||||
MAPM m_m;
|
||||
|
||||
static const MAPM arg_a;
|
||||
static const MAPM arg_c;
|
||||
|
||||
MAPM m_remainder;
|
||||
|
||||
pgsVectorMapm m_buffer;
|
||||
|
||||
public:
|
||||
|
||||
pgsSequentialIntGen(const MAPM &range, const long &seed);
|
||||
|
||||
virtual MAPM random();
|
||||
|
||||
virtual ~pgsSequentialIntGen();
|
||||
|
||||
virtual pgsNumberGen *clone();
|
||||
|
||||
/* pgsSequentialIntGen & operator =(const pgsSequentialIntGen & that); */
|
||||
|
||||
/* pgsSequentialIntGen(const pgsSequentialIntGen & that); */
|
||||
};
|
||||
|
||||
class pgsNormalIntGen : public pgsNumberGen
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
MAPM m_state;
|
||||
MAPM m_top;
|
||||
|
||||
static const MAPM arg_a;
|
||||
static const MAPM arg_c;
|
||||
static const MAPM arg_m;
|
||||
|
||||
public:
|
||||
|
||||
pgsNormalIntGen(const MAPM &range, const long &seed);
|
||||
|
||||
virtual MAPM random();
|
||||
|
||||
virtual ~pgsNormalIntGen();
|
||||
|
||||
virtual pgsNumberGen *clone();
|
||||
|
||||
/* pgsNormalIntGen & operator =(const pgsNormalIntGen & that); */
|
||||
|
||||
/* pgsNormalIntGen(const pgsNormalIntGen & that); */
|
||||
};
|
||||
|
||||
friend class pgsRealGen;
|
||||
|
||||
private:
|
||||
|
||||
typedef pgsCopiedPtr<pgsNumberGen> pgsRandomizer; // Needs a clone() method
|
||||
|
||||
MAPM m_min;
|
||||
MAPM m_max;
|
||||
MAPM m_range;
|
||||
|
||||
bool m_sequence;
|
||||
|
||||
pgsRandomizer m_randomizer;
|
||||
|
||||
public:
|
||||
|
||||
pgsIntegerGen(const MAPM &min, const MAPM &max,
|
||||
const bool &sequence = false, const long &seed = wxDateTime::GetTimeNow());
|
||||
|
||||
bool is_sequence() const;
|
||||
|
||||
virtual wxString random();
|
||||
|
||||
long random_long();
|
||||
|
||||
virtual ~pgsIntegerGen();
|
||||
|
||||
virtual pgsIntegerGen *clone();
|
||||
|
||||
/* pgsIntegerGen & operator =(const pgsIntegerGen & that); */
|
||||
|
||||
/* pgsIntegerGen(const pgsIntegerGen & that); */
|
||||
};
|
||||
|
||||
#endif /*PGSINTEGERGEN_H_*/
|
||||
41
include/pgscript/generators/pgsNumberGen.h
Normal file
41
include/pgscript/generators/pgsNumberGen.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSNUMBERGEN_H_
|
||||
#define PGSNUMBERGEN_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/utilities/pgsMapm.h"
|
||||
|
||||
class pgsNumberGen
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
MAPM m_range;
|
||||
|
||||
static const int BUFFER_SIZE = 1000;
|
||||
|
||||
pgsNumberGen(const MAPM &range);
|
||||
|
||||
public:
|
||||
|
||||
virtual ~pgsNumberGen();
|
||||
|
||||
virtual MAPM random() = 0;
|
||||
|
||||
virtual pgsNumberGen *clone() = 0;
|
||||
|
||||
/* pgsNumberGen & operator =(const pgsNumberGen & that); */
|
||||
|
||||
/* pgsNumberGen(const pgsNumberGen & that); */
|
||||
};
|
||||
|
||||
#endif /*PGSNUMBERGEN_H_*/
|
||||
40
include/pgscript/generators/pgsObjectGen.h
Normal file
40
include/pgscript/generators/pgsObjectGen.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSOBJECTGEN_H_
|
||||
#define PGSOBJECTGEN_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include <wx/datetime.h>
|
||||
|
||||
class pgsObjectGen
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
long m_seed;
|
||||
|
||||
pgsObjectGen(const long &seed = wxDateTime::GetTimeNow());
|
||||
|
||||
/* pgsObjectGen & operator =(const pgsObjectGen & that); */
|
||||
|
||||
/* pgsObjectGen(const pgsObjectGen & that); */
|
||||
|
||||
public:
|
||||
|
||||
virtual ~pgsObjectGen();
|
||||
|
||||
virtual wxString random() = 0;
|
||||
|
||||
virtual pgsObjectGen *clone() = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSOBJECTGEN_H_*/
|
||||
56
include/pgscript/generators/pgsRealGen.h
Normal file
56
include/pgscript/generators/pgsRealGen.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef RANDREAL_H_
|
||||
#define RANDREAL_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/generators/pgsIntegerGen.h"
|
||||
|
||||
class pgsRealGen : public pgsObjectGen
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
typedef pgsCopiedPtr<pgsNumberGen> pgsRandomizer; // Needs a clone() method
|
||||
|
||||
MAPM m_min;
|
||||
MAPM m_max;
|
||||
MAPM m_range;
|
||||
|
||||
bool m_sequence;
|
||||
|
||||
MAPM m_pow;
|
||||
MAPM m_int_max;
|
||||
|
||||
pgsRandomizer m_randomizer;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Builds a new real number generator. Precision cannot be greater that 255.
|
||||
*/
|
||||
pgsRealGen(const MAPM &min, const MAPM &max, const UCHAR &precision,
|
||||
const bool &sequence = false, const long &seed = wxDateTime::GetTimeNow());
|
||||
|
||||
bool is_sequence() const;
|
||||
|
||||
virtual wxString random();
|
||||
|
||||
virtual ~pgsRealGen();
|
||||
|
||||
virtual pgsRealGen *clone();
|
||||
|
||||
/* pgsRealGen & operator =(const pgsRealGen & that); */
|
||||
|
||||
/* pgsRealGen(const pgsRealGen & that); */
|
||||
};
|
||||
|
||||
#endif /*RANDREAL_H_*/
|
||||
53
include/pgscript/generators/pgsReferenceGen.h
Normal file
53
include/pgscript/generators/pgsReferenceGen.h
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSREFERENCEGEN_H_
|
||||
#define PGSREFERENCEGEN_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/generators/pgsIntegerGen.h"
|
||||
|
||||
class pgsThread;
|
||||
|
||||
class pgsReferenceGen : public pgsObjectGen
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
typedef pgsCopiedPtr<pgsIntegerGen> pgsRandomizer; // Needs a clone() method
|
||||
|
||||
pgsThread *m_app;
|
||||
wxString m_table;
|
||||
wxString m_column;
|
||||
bool m_sequence;
|
||||
|
||||
MAPM m_nb_rows;
|
||||
|
||||
pgsRandomizer m_randomizer;
|
||||
|
||||
public:
|
||||
|
||||
pgsReferenceGen(pgsThread *app, const wxString &table, const wxString &column,
|
||||
const bool &sequence = false, const long &seed = wxDateTime::GetTimeNow());
|
||||
|
||||
bool is_sequence() const;
|
||||
|
||||
virtual wxString random();
|
||||
|
||||
virtual ~pgsReferenceGen();
|
||||
|
||||
virtual pgsReferenceGen *clone();
|
||||
|
||||
/* pgsReferenceGen & operator =(const pgsReferenceGen & that); */
|
||||
|
||||
/* pgsReferenceGen(const pgsReferenceGen & that); */
|
||||
};
|
||||
|
||||
#endif /*PGSREFERENCEGEN_H_*/
|
||||
102
include/pgscript/generators/pgsRegexGen.h
Normal file
102
include/pgscript/generators/pgsRegexGen.h
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSREGEXGEN_H_
|
||||
#define PGSREGEXGEN_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/generators/pgsObjectGen.h"
|
||||
#include "pgscript/generators/pgsStringGen.h"
|
||||
|
||||
WX_DECLARE_OBJARRAY(pgsStringGen, pgsVectorStringGen);
|
||||
|
||||
class pgsRegexGen : public pgsObjectGen
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
class pgsRegex
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
pgsVectorChar m_characters;
|
||||
|
||||
long m_first;
|
||||
long m_second;
|
||||
|
||||
public:
|
||||
|
||||
pgsRegex(const pgsVectorChar &characters, const long &first,
|
||||
const long &second);
|
||||
|
||||
pgsRegex();
|
||||
|
||||
~pgsRegex();
|
||||
|
||||
pgsRegex *clone();
|
||||
|
||||
/* pgsRegex & operator =(const pgsRegex & that); */
|
||||
|
||||
/* pgsRegex(const pgsRegex & that); */
|
||||
|
||||
void set_characters(const pgsVectorChar &characters);
|
||||
|
||||
void add_character(const wxChar &c);
|
||||
|
||||
void set_first(const long &first);
|
||||
|
||||
void set_second(const long &second);
|
||||
|
||||
const pgsVectorChar &get_characters() const;
|
||||
|
||||
const long &get_first() const;
|
||||
|
||||
const long &get_second() const;
|
||||
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
wxString m_regex;
|
||||
|
||||
bool m_valid;
|
||||
|
||||
pgsVectorStringGen m_string_gens;
|
||||
|
||||
public:
|
||||
|
||||
pgsRegexGen(const wxString ®ex, const long &seed = wxDateTime::GetTimeNow());
|
||||
|
||||
virtual wxString random();
|
||||
|
||||
virtual ~pgsRegexGen();
|
||||
|
||||
virtual pgsRegexGen *clone();
|
||||
|
||||
/* pgsRegexGen & operator =(const pgsRegexGen & that); */
|
||||
|
||||
/* pgsRegexGen(const pgsRegexGen & that); */
|
||||
|
||||
const bool &is_valid() const;
|
||||
|
||||
const pgsVectorStringGen &string_gens() const;
|
||||
|
||||
size_t string_gens_size() const;
|
||||
|
||||
private:
|
||||
|
||||
static wxString espace_xml_char(const wxChar &c);
|
||||
|
||||
static wxString char_range(const wxChar &b, const wxChar &c);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSREGEXGEN_H_*/
|
||||
54
include/pgscript/generators/pgsStringGen.h
Normal file
54
include/pgscript/generators/pgsStringGen.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSSTRINGGEN_H_
|
||||
#define PGSSTRINGGEN_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/generators/pgsIntegerGen.h"
|
||||
|
||||
WX_DECLARE_OBJARRAY(wxChar, pgsVectorChar);
|
||||
|
||||
class pgsStringGen : public pgsObjectGen
|
||||
{
|
||||
private:
|
||||
|
||||
typedef pgsCopiedPtr<pgsIntegerGen> pgsRandomizer; // Needs a clone() method
|
||||
|
||||
pgsRandomizer m_w_size_randomizer;
|
||||
pgsRandomizer m_letter_randomizer;
|
||||
|
||||
UCHAR m_nb_words;
|
||||
|
||||
pgsVectorChar m_characters;
|
||||
|
||||
public:
|
||||
|
||||
pgsStringGen(USHORT w_size_min, USHORT w_size_max = 0, const UCHAR &nb_words = 1,
|
||||
const long &seed = wxDateTime::GetTimeNow(),
|
||||
pgsVectorChar characters = pgsVectorChar());
|
||||
|
||||
virtual wxString random();
|
||||
|
||||
virtual ~pgsStringGen();
|
||||
|
||||
virtual pgsStringGen *clone();
|
||||
|
||||
/* pgsStringGen & operator =(const pgsStringGen & that); */
|
||||
|
||||
/* pgsStringGen(const pgsStringGen & that); */
|
||||
|
||||
private:
|
||||
|
||||
void init_characters();
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSSTRINGGEN_H_*/
|
||||
51
include/pgscript/generators/pgsTimeGen.h
Normal file
51
include/pgscript/generators/pgsTimeGen.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSTIMEGEN_H_
|
||||
#define PGSTIMEGEN_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include <wx/datetime.h>
|
||||
#include "pgscript/generators/pgsIntegerGen.h"
|
||||
|
||||
class pgsTimeGen : public pgsObjectGen
|
||||
{
|
||||
private:
|
||||
|
||||
typedef pgsCopiedPtr<pgsIntegerGen> pgsRandomizer; // Needs a clone() method
|
||||
|
||||
wxDateTime m_min;
|
||||
wxDateTime m_max;
|
||||
wxLongLong m_range;
|
||||
|
||||
bool m_sequence;
|
||||
|
||||
pgsRandomizer m_randomizer;
|
||||
|
||||
public:
|
||||
|
||||
pgsTimeGen(wxDateTime min, wxDateTime max, const bool &sequence,
|
||||
const long &seed = wxDateTime::GetTimeNow());
|
||||
|
||||
bool is_sequence() const;
|
||||
|
||||
virtual wxString random();
|
||||
|
||||
virtual ~pgsTimeGen();
|
||||
|
||||
virtual pgsTimeGen *clone();
|
||||
|
||||
/* pgsTimeGen & operator =(const pgsTimeGen & that); */
|
||||
|
||||
/* pgsTimeGen(const pgsTimeGen & that); */
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSTIMEGEN_H_*/
|
||||
145
include/pgscript/location.hh
Normal file
145
include/pgscript/location.hh
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
|
||||
/* Locations for Bison parsers in C++
|
||||
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/**
|
||||
** \file location.hh
|
||||
** Define the pgscript::location class.
|
||||
*/
|
||||
|
||||
#ifndef BISON_LOCATION_HH
|
||||
# define BISON_LOCATION_HH
|
||||
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
# include "position.hh"
|
||||
|
||||
namespace pgscript
|
||||
{
|
||||
|
||||
/// Abstract a location.
|
||||
class location
|
||||
{
|
||||
public:
|
||||
|
||||
/// Construct a location.
|
||||
location ()
|
||||
: begin (), end ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// Initialization.
|
||||
inline void initialize (std::string* fn)
|
||||
{
|
||||
begin.initialize (fn);
|
||||
end = begin;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
public:
|
||||
/// Reset initial location to final location.
|
||||
inline void step ()
|
||||
{
|
||||
begin = end;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next columns.
|
||||
inline void columns (unsigned int count = 1)
|
||||
{
|
||||
end += count;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next lines.
|
||||
inline void lines (unsigned int count = 1)
|
||||
{
|
||||
end.lines (count);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
|
||||
public:
|
||||
/// Beginning of the located region.
|
||||
position begin;
|
||||
/// End of the located region.
|
||||
position end;
|
||||
};
|
||||
|
||||
/// Join two location objects to create a location.
|
||||
inline const location operator+ (const location& begin, const location& end)
|
||||
{
|
||||
location res = begin;
|
||||
res.end = end.end;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add two location objects.
|
||||
inline const location operator+ (const location& begin, unsigned int width)
|
||||
{
|
||||
location res = begin;
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add and assign a location.
|
||||
inline location& operator+= (location& res, unsigned int width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/** \brief Intercept output stream redirection.
|
||||
** \param ostr the destination output stream
|
||||
** \param loc a reference to the location to redirect
|
||||
**
|
||||
** Avoid duplicate information.
|
||||
*/
|
||||
inline std::ostream& operator<< (std::ostream& ostr, const location& loc)
|
||||
{
|
||||
position last = loc.end - 1;
|
||||
ostr << loc.begin;
|
||||
if (last.filename
|
||||
&& (!loc.begin.filename
|
||||
|| *loc.begin.filename != *last.filename))
|
||||
ostr << '-' << last;
|
||||
else if (loc.begin.line != last.line)
|
||||
ostr << '-' << last.line << '.' << last.column;
|
||||
else if (loc.begin.column != last.column)
|
||||
ostr << '-' << last.column;
|
||||
return ostr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // not BISON_LOCATION_HH
|
||||
29
include/pgscript/module.mk
Normal file
29
include/pgscript/module.mk
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#######################################################################
|
||||
#
|
||||
# pgAdmin III - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
# module.mk - pgadmin/include/pgscript/ Makefile fragment
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
pgadmin3_SOURCES += \
|
||||
include/pgscript/location.hh \
|
||||
include/pgscript/parser.tab.hh \
|
||||
include/pgscript/position.hh \
|
||||
include/pgscript/stack.hh \
|
||||
include/pgscript/FlexLexer.h \
|
||||
include/pgscript/pgsApplication.h \
|
||||
include/pgscript/pgScript.h
|
||||
|
||||
EXTRA_DIST += \
|
||||
include/pgscript/module.mk
|
||||
|
||||
include include/pgscript/exceptions/module.mk
|
||||
include include/pgscript/expressions/module.mk
|
||||
include include/pgscript/generators/module.mk
|
||||
include include/pgscript/objects/module.mk
|
||||
include include/pgscript/statements/module.mk
|
||||
include include/pgscript/utilities/module.mk
|
||||
22
include/pgscript/objects/module.mk
Normal file
22
include/pgscript/objects/module.mk
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#######################################################################
|
||||
#
|
||||
# pgAdmin III - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
# module.mk - pgadmin/include/pgscript/objects/ Makefile fragment
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
pgadmin3_SOURCES += \
|
||||
include/pgscript/objects/pgsGenerator.h \
|
||||
include/pgscript/objects/pgsNumber.h \
|
||||
include/pgscript/objects/pgsObjects.h \
|
||||
include/pgscript/objects/pgsRecord.h \
|
||||
include/pgscript/objects/pgsString.h \
|
||||
include/pgscript/objects/pgsVariable.h
|
||||
|
||||
EXTRA_DIST += \
|
||||
include/pgscript/objects/module.mk
|
||||
|
||||
94
include/pgscript/objects/pgsGenerator.h
Normal file
94
include/pgscript/objects/pgsGenerator.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSGENERATOR_H_
|
||||
#define PGSGENERATOR_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/generators/pgsObjectGen.h"
|
||||
#include "pgscript/objects/pgsVariable.h"
|
||||
#include "pgscript/utilities/pgsSharedPtr.h"
|
||||
|
||||
class pgsNumber;
|
||||
class pgsRecord;
|
||||
class pgsString;
|
||||
|
||||
class pgsGenerator : public pgsVariable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual pgsOperand pgs_plus(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_minus(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_times(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_over(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_modulo(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_equal(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_different(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_greater(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_lower(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_lower_equal(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_greater_equal(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_not() const;
|
||||
|
||||
virtual bool pgs_is_true() const;
|
||||
|
||||
virtual pgsOperand pgs_almost_equal(const pgsVariable &rhs) const;
|
||||
|
||||
protected:
|
||||
|
||||
typedef pgsSharedPtr<pgsObjectGen> pgsRandomizer;
|
||||
|
||||
mutable pgsRandomizer m_randomizer;
|
||||
|
||||
public:
|
||||
|
||||
pgsGenerator(const pgsTypes &generator_type, pgsObjectGen *randomizer);
|
||||
|
||||
virtual ~pgsGenerator();
|
||||
|
||||
virtual pgsVariable *clone() const;
|
||||
|
||||
/* pgsGenerator(const pgsGenerator & that); */
|
||||
|
||||
/* pgsGenerator & operator =(const pgsGenerator & that); */
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
protected:
|
||||
|
||||
pgsOperand operand() const;
|
||||
|
||||
public:
|
||||
|
||||
virtual pgsNumber number() const;
|
||||
|
||||
virtual pgsRecord record() const;
|
||||
|
||||
virtual pgsString string() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSGENERATOR_H_*/
|
||||
98
include/pgscript/objects/pgsNumber.h
Normal file
98
include/pgscript/objects/pgsNumber.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSNUMBER_H_
|
||||
#define PGSNUMBER_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/objects/pgsVariable.h"
|
||||
|
||||
class pgsRecord;
|
||||
class pgsString;
|
||||
|
||||
/**
|
||||
* A pgsNumber represents either a number or a string. If the data (a string)
|
||||
* matches with a regular expression that represents a number then it is a
|
||||
* number otherwise it is a string. The difference between a string stored
|
||||
* in this object and a string stored in pgsString is that a string in pgsNumber
|
||||
* cannot be concatenated with another one in pgsPlus.
|
||||
*/
|
||||
class pgsNumber : public pgsVariable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual pgsOperand pgs_plus(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_minus(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_times(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_over(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_modulo(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_equal(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_different(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_greater(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_lower(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_lower_equal(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_greater_equal(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_not() const;
|
||||
|
||||
virtual bool pgs_is_true() const;
|
||||
|
||||
virtual pgsOperand pgs_almost_equal(const pgsVariable &rhs) const;
|
||||
|
||||
protected:
|
||||
|
||||
wxString m_data;
|
||||
|
||||
public:
|
||||
|
||||
explicit pgsNumber(const wxString &data, const bool &is_real = pgsInt);
|
||||
|
||||
virtual ~pgsNumber();
|
||||
|
||||
virtual pgsVariable *clone() const;
|
||||
|
||||
pgsNumber(const pgsNumber &that);
|
||||
|
||||
pgsNumber &operator =(const pgsNumber &that);
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
public:
|
||||
|
||||
bool is_valid() const;
|
||||
|
||||
static pgsTypes num_type(const wxString &num);
|
||||
|
||||
public:
|
||||
|
||||
virtual pgsNumber number() const;
|
||||
|
||||
virtual pgsRecord record() const;
|
||||
|
||||
virtual pgsString string() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSNUMBER_H_*/
|
||||
20
include/pgscript/objects/pgsObjects.h
Normal file
20
include/pgscript/objects/pgsObjects.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSOBJECTS_H_
|
||||
#define PGSOBJECTS_H_
|
||||
|
||||
#include "pgsGenerator.h"
|
||||
#include "pgsNumber.h"
|
||||
#include "pgsRecord.h"
|
||||
#include "pgsString.h"
|
||||
#include "pgsVariable.h"
|
||||
|
||||
#endif /*PGSOBJECTS_H_*/
|
||||
155
include/pgscript/objects/pgsRecord.h
Normal file
155
include/pgscript/objects/pgsRecord.h
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSRECORD_H_
|
||||
#define PGSRECORD_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/objects/pgsVariable.h"
|
||||
|
||||
WX_DECLARE_OBJARRAY(pgsOperand, pgsVectorRecordLine);
|
||||
WX_DECLARE_OBJARRAY(pgsVectorRecordLine, pgsVectorRecord);
|
||||
|
||||
class pgsNumber;
|
||||
class pgsString;
|
||||
|
||||
class pgsRecord : public pgsVariable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual pgsOperand pgs_plus(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_minus(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_times(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_over(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_modulo(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_equal(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_different(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_greater(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_lower(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_lower_equal(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_greater_equal(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_not() const;
|
||||
|
||||
virtual bool pgs_is_true() const;
|
||||
|
||||
virtual pgsOperand pgs_almost_equal(const pgsVariable &rhs) const;
|
||||
|
||||
protected:
|
||||
|
||||
pgsVectorRecord m_record;
|
||||
|
||||
wxArrayString m_columns;
|
||||
|
||||
public:
|
||||
|
||||
explicit pgsRecord(const USHORT &nb_columns);
|
||||
|
||||
virtual ~pgsRecord();
|
||||
|
||||
virtual pgsVariable *clone() const;
|
||||
|
||||
/* pgsRecord(const pgsRecord & that); */
|
||||
|
||||
/* pgsRecord & operator =(const pgsRecord & that); */
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
public:
|
||||
|
||||
USHORT count_lines() const;
|
||||
|
||||
USHORT count_columns() const;
|
||||
|
||||
/**
|
||||
* Inserts a new element at line.column. If there is something then
|
||||
* it is deleted before inserting the new element.
|
||||
*/
|
||||
bool insert(const USHORT &line, const USHORT &column,
|
||||
pgsOperand value);
|
||||
|
||||
/**
|
||||
* Retrieves the element at line.column. If it does not exist it
|
||||
* returns an empty string.
|
||||
*/
|
||||
pgsOperand get(const USHORT &line,
|
||||
const USHORT &column) const;
|
||||
|
||||
pgsOperand get_line(const USHORT &line) const;
|
||||
|
||||
/**
|
||||
* Sets the name of a column. If the index is too high or if the name
|
||||
* already exists then false is returned.
|
||||
*/
|
||||
bool set_column_name(const USHORT &column, wxString name);
|
||||
|
||||
/**
|
||||
* Gets the index of a given column. If this column does not exist then it
|
||||
* returns count_columns() (the number of columns) which means that this value
|
||||
* is unusable. So if get_column(...) == count_colums() an error occurred.
|
||||
*/
|
||||
USHORT get_column(wxString name) const;
|
||||
|
||||
bool remove_line(const USHORT &line);
|
||||
|
||||
private:
|
||||
|
||||
bool newline();
|
||||
|
||||
bool valid() const;
|
||||
|
||||
public:
|
||||
|
||||
bool operator==(const pgsRecord &rhs) const;
|
||||
|
||||
bool operator!=(const pgsRecord &rhs) const;
|
||||
|
||||
bool operator<(const pgsRecord &rhs) const;
|
||||
|
||||
bool operator>(const pgsRecord &rhs) const;
|
||||
|
||||
bool operator<=(const pgsRecord &rhs) const;
|
||||
|
||||
bool operator>=(const pgsRecord &rhs) const;
|
||||
|
||||
bool almost_equal(const pgsRecord &rhs) const;
|
||||
|
||||
private:
|
||||
|
||||
bool records_equal(const pgsRecord &lhs, const pgsRecord &rhs,
|
||||
bool case_sensitive = true) const;
|
||||
|
||||
bool lines_equal(const pgsVectorRecordLine &lhs,
|
||||
const pgsVectorRecordLine &rhs, bool case_sensitive = true) const;
|
||||
|
||||
public:
|
||||
|
||||
virtual pgsNumber number() const;
|
||||
|
||||
virtual pgsRecord record() const;
|
||||
|
||||
virtual pgsString string() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSRECORD_H_*/
|
||||
85
include/pgscript/objects/pgsString.h
Normal file
85
include/pgscript/objects/pgsString.h
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSSTRING_H_
|
||||
#define PGSSTRING_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/objects/pgsVariable.h"
|
||||
|
||||
class pgsRecord;
|
||||
class pgsString;
|
||||
|
||||
class pgsString : public pgsVariable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual pgsOperand pgs_plus(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_minus(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_times(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_over(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_modulo(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_equal(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_different(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_greater(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_lower(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_lower_equal(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_greater_equal(const pgsVariable &rhs) const;
|
||||
|
||||
virtual pgsOperand pgs_not() const;
|
||||
|
||||
virtual bool pgs_is_true() const;
|
||||
|
||||
virtual pgsOperand pgs_almost_equal(const pgsVariable &rhs) const;
|
||||
|
||||
protected:
|
||||
|
||||
wxString m_data;
|
||||
|
||||
public:
|
||||
|
||||
explicit pgsString(const wxString &data);
|
||||
|
||||
virtual ~pgsString();
|
||||
|
||||
virtual pgsVariable *clone() const;
|
||||
|
||||
/* pgsString(const pgsString & that); */
|
||||
|
||||
/* pgsString & operator =(const pgsString & that); */
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const;
|
||||
|
||||
public:
|
||||
|
||||
virtual pgsNumber number() const;
|
||||
|
||||
virtual pgsRecord record() const;
|
||||
|
||||
virtual pgsString string() const;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSSTRING_H_*/
|
||||
138
include/pgscript/objects/pgsVariable.h
Normal file
138
include/pgscript/objects/pgsVariable.h
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSVARIABLE_H_
|
||||
#define PGSVARIABLE_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/utilities/pgsMapm.h"
|
||||
#include "pgscript/expressions/pgsExpression.h"
|
||||
|
||||
class pgsNumber;
|
||||
class pgsRecord;
|
||||
class pgsString;
|
||||
|
||||
class pgsVariable : public pgsExpression
|
||||
{
|
||||
|
||||
friend pgsOperand operator+(const pgsVariable &lhs, const pgsVariable &rhs);
|
||||
|
||||
friend pgsOperand operator-(const pgsVariable &lhs, const pgsVariable &rhs);
|
||||
|
||||
friend pgsOperand operator*(const pgsVariable &lhs, const pgsVariable &rhs);
|
||||
|
||||
friend pgsOperand operator/(const pgsVariable &lhs, const pgsVariable &rhs);
|
||||
|
||||
friend pgsOperand operator%(const pgsVariable &lhs, const pgsVariable &rhs);
|
||||
|
||||
friend pgsOperand operator==(const pgsVariable &lhs, const pgsVariable &rhs);
|
||||
|
||||
friend pgsOperand operator!=(const pgsVariable &lhs, const pgsVariable &rhs);
|
||||
|
||||
friend pgsOperand operator<(const pgsVariable &lhs, const pgsVariable &rhs);
|
||||
|
||||
friend pgsOperand operator>(const pgsVariable &lhs, const pgsVariable &rhs);
|
||||
|
||||
friend pgsOperand operator<=(const pgsVariable &lhs, const pgsVariable &rhs);
|
||||
|
||||
friend pgsOperand operator>=(const pgsVariable &lhs, const pgsVariable &rhs);
|
||||
|
||||
friend pgsOperand operator!(const pgsVariable &lhs);
|
||||
|
||||
friend pgsOperand operator&=(const pgsVariable &lhs, const pgsVariable &rhs);
|
||||
|
||||
public:
|
||||
|
||||
virtual pgsOperand pgs_plus(const pgsVariable &rhs) const = 0;
|
||||
|
||||
virtual pgsOperand pgs_minus(const pgsVariable &rhs) const = 0;
|
||||
|
||||
virtual pgsOperand pgs_times(const pgsVariable &rhs) const = 0;
|
||||
|
||||
virtual pgsOperand pgs_over(const pgsVariable &rhs) const = 0;
|
||||
|
||||
virtual pgsOperand pgs_modulo(const pgsVariable &rhs) const = 0;
|
||||
|
||||
virtual pgsOperand pgs_equal(const pgsVariable &rhs) const = 0;
|
||||
|
||||
virtual pgsOperand pgs_different(const pgsVariable &rhs) const = 0;
|
||||
|
||||
virtual pgsOperand pgs_greater(const pgsVariable &rhs) const = 0;
|
||||
|
||||
virtual pgsOperand pgs_lower(const pgsVariable &rhs) const = 0;
|
||||
|
||||
virtual pgsOperand pgs_lower_equal(const pgsVariable &rhs) const = 0;
|
||||
|
||||
virtual pgsOperand pgs_greater_equal(const pgsVariable &rhs) const = 0;
|
||||
|
||||
virtual pgsOperand pgs_not() const = 0;
|
||||
|
||||
virtual bool pgs_is_true() const = 0;
|
||||
|
||||
virtual pgsOperand pgs_almost_equal(const pgsVariable &rhs) const = 0;
|
||||
|
||||
public:
|
||||
|
||||
enum pgsTypes
|
||||
{
|
||||
pgsTReal, pgsTInt, pgsTString, pgsTRecord
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
pgsVariable(const pgsTypes &type);
|
||||
|
||||
pgsTypes m_type;
|
||||
|
||||
public:
|
||||
|
||||
virtual ~pgsVariable();
|
||||
|
||||
virtual pgsVariable *clone() const = 0;
|
||||
|
||||
/* pgsVariable(const pgsVariable & that); */
|
||||
|
||||
/* pgsVariable & operator =(const pgsVariable & that); */
|
||||
|
||||
static MAPM num(const pgsOperand &var);
|
||||
|
||||
static MAPM num(const wxString &var);
|
||||
|
||||
public:
|
||||
|
||||
virtual wxString value() const = 0;
|
||||
|
||||
virtual pgsOperand eval(pgsVarMap &vars) const = 0;
|
||||
|
||||
public:
|
||||
|
||||
bool is_number() const;
|
||||
|
||||
bool is_integer() const;
|
||||
|
||||
bool is_real() const;
|
||||
|
||||
bool is_string() const;
|
||||
|
||||
bool is_record() const;
|
||||
|
||||
const pgsTypes &type() const;
|
||||
|
||||
public:
|
||||
|
||||
virtual pgsNumber number() const = 0;
|
||||
|
||||
virtual pgsRecord record() const = 0;
|
||||
|
||||
virtual pgsString string() const = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSVARIABLE_H_*/
|
||||
403
include/pgscript/parser.tab.hh
Normal file
403
include/pgscript/parser.tab.hh
Normal file
|
|
@ -0,0 +1,403 @@
|
|||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
|
||||
/* Skeleton interface for Bison LALR(1) parsers in C++
|
||||
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/* C++ LALR(1) parser skeleton written by Akim Demaille. */
|
||||
|
||||
#ifndef PARSER_HEADER_H
|
||||
# define PARSER_HEADER_H
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "stack.hh"
|
||||
|
||||
namespace pgscript
|
||||
{
|
||||
class position;
|
||||
class location;
|
||||
}
|
||||
|
||||
/* First part of user declarations. */
|
||||
#line 1 "pgscript/pgsParser.yy"
|
||||
/*** C/C++ Declarations ***/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/statements/pgsStatements.h"
|
||||
#include "pgscript/expressions/pgsExpressions.h"
|
||||
#include "pgscript/objects/pgsObjects.h"
|
||||
#include "pgscript/utilities/pgsContext.h"
|
||||
|
||||
|
||||
|
||||
/* Line 35 of lalr1.cc. */
|
||||
#line 73 "pgscript/parser.tab.hh"
|
||||
|
||||
#include "location.hh"
|
||||
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
# define YYDEBUG 0
|
||||
#endif
|
||||
|
||||
/* Enabling verbose error messages. */
|
||||
#ifdef YYERROR_VERBOSE
|
||||
# undef YYERROR_VERBOSE
|
||||
# define YYERROR_VERBOSE 1
|
||||
#else
|
||||
# define YYERROR_VERBOSE 1
|
||||
#endif
|
||||
|
||||
/* Enabling the token table. */
|
||||
#ifndef YYTOKEN_TABLE
|
||||
# define YYTOKEN_TABLE 0
|
||||
#endif
|
||||
|
||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||
If N is 0, then set CURRENT to the empty location which ends
|
||||
the previous symbol: RHS[0] (always defined). */
|
||||
|
||||
#ifndef YYLLOC_DEFAULT
|
||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
do { \
|
||||
if (N) \
|
||||
{ \
|
||||
(Current).begin = (Rhs)[1].begin; \
|
||||
(Current).end = (Rhs)[N].end; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(Current).begin = (Current).end = (Rhs)[0].end; \
|
||||
} \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
namespace pgscript
|
||||
{
|
||||
|
||||
/// A Bison parser.
|
||||
class pgsParser
|
||||
{
|
||||
public:
|
||||
/// Symbol semantic values.
|
||||
#ifndef YYSTYPE
|
||||
union semantic_type
|
||||
#line 106 "pgscript/pgsParser.yy"
|
||||
{
|
||||
const wxString * str;
|
||||
int integer;
|
||||
pgsExpression * expr;
|
||||
pgsStmt * stmt;
|
||||
pgsStmtList * stmt_list;
|
||||
}
|
||||
/* Line 35 of lalr1.cc. */
|
||||
#line 133 "pgscript/parser.tab.hh"
|
||||
;
|
||||
#else
|
||||
typedef YYSTYPE semantic_type;
|
||||
#endif
|
||||
/// Symbol locations.
|
||||
typedef location location_type;
|
||||
/// Tokens.
|
||||
struct token
|
||||
{
|
||||
/* Tokens. */
|
||||
enum yytokentype {
|
||||
PGS_END = 0,
|
||||
PGS_WHILE = 258,
|
||||
PGS_BREAK = 259,
|
||||
PGS_RETURN = 260,
|
||||
PGS_CONTINUE = 261,
|
||||
PGS_IF = 262,
|
||||
PGS_ELSE = 263,
|
||||
PGS_WAITFOR = 264,
|
||||
PGS_AS = 265,
|
||||
PGS_OPEN = 266,
|
||||
PGS_CLOSE = 267,
|
||||
PGS_ASSERT = 268,
|
||||
PGS_PRINT = 269,
|
||||
PGS_LOG = 270,
|
||||
PGS_CNT_COLUMNS = 271,
|
||||
PGS_CNT_LINES = 272,
|
||||
PGS_TRIM = 273,
|
||||
PGS_RM_LINE = 274,
|
||||
PGS_CAST = 275,
|
||||
PGS_RECORD = 276,
|
||||
PGS_INTEGER = 277,
|
||||
PGS_REAL = 278,
|
||||
PGS_STRING = 279,
|
||||
PGS_REGEX = 280,
|
||||
PGS_FILE = 281,
|
||||
PGS_DATE = 282,
|
||||
PGS_TIME = 283,
|
||||
PGS_DATE_TIME = 284,
|
||||
PGS_REFERENCE = 285,
|
||||
PGS_LE_OP = 286,
|
||||
PGS_GE_OP = 287,
|
||||
PGS_EQ_OP = 288,
|
||||
PGS_AE_OP = 289,
|
||||
PGS_NE_OP = 290,
|
||||
PGS_AND_OP = 291,
|
||||
PGS_OR_OP = 292,
|
||||
PGS_NOT_OP = 293,
|
||||
PGS_UNKNOWN = 294,
|
||||
PGS_SET_ASSIGN = 295,
|
||||
PGS_DECLARE_ASSGN = 296,
|
||||
PGS_ABORT = 297,
|
||||
PGS_ALTER = 298,
|
||||
PGS_ANALYZE = 299,
|
||||
PGS_BEGIN = 300,
|
||||
PGS_CHECKPOINT = 301,
|
||||
PGS_CLOSE_ST = 302,
|
||||
PGS_CLUSTER = 303,
|
||||
PGS_COMMENT = 304,
|
||||
PGS_COMMIT = 305,
|
||||
PGS_COPY = 306,
|
||||
PGS_CREATE = 307,
|
||||
PGS_DEALLOCATE = 308,
|
||||
PGS_DECLARE = 309,
|
||||
PGS_DELETE = 310,
|
||||
PGS_DISCARD = 311,
|
||||
PGS_DROP = 312,
|
||||
PGS_END_ST = 313,
|
||||
PGS_EXECUTE = 314,
|
||||
PGS_EXPLAIN = 315,
|
||||
PGS_FETCH = 316,
|
||||
PGS_GRANT = 317,
|
||||
PGS_INSERT = 318,
|
||||
PGS_LISTEN = 319,
|
||||
PGS_LOAD = 320,
|
||||
PGS_LOCK = 321,
|
||||
PGS_MOVE = 322,
|
||||
PGS_NOTIFY = 323,
|
||||
PGS_PREPARE = 324,
|
||||
PGS_REASSIGN = 325,
|
||||
PGS_REINDEX = 326,
|
||||
PGS_RELEASE = 327,
|
||||
PGS_RESET = 328,
|
||||
PGS_REVOKE = 329,
|
||||
PGS_ROLLBACK = 330,
|
||||
PGS_SAVEPOINT = 331,
|
||||
PGS_SELECT = 332,
|
||||
PGS_SET = 333,
|
||||
PGS_SHOW = 334,
|
||||
PGS_START = 335,
|
||||
PGS_TRUNCATE = 336,
|
||||
PGS_UNLISTEN = 337,
|
||||
PGS_UPDATE = 338,
|
||||
PGS_VACUUM = 339,
|
||||
PGS_VALUES = 340,
|
||||
PGS_IDENTIFIER = 341,
|
||||
PGS_VAL_INT = 342,
|
||||
PGS_VAL_REAL = 343,
|
||||
PGS_VAL_STR = 344
|
||||
};
|
||||
|
||||
};
|
||||
/// Token type.
|
||||
typedef token::yytokentype token_type;
|
||||
|
||||
/// Build a parser object.
|
||||
pgsParser (class pgsDriver & driver_yyarg);
|
||||
virtual ~pgsParser ();
|
||||
|
||||
/// Parse.
|
||||
/// \returns 0 iff parsing succeeded.
|
||||
virtual int parse ();
|
||||
|
||||
/// The current debugging stream.
|
||||
std::ostream& debug_stream () const;
|
||||
/// Set the current debugging stream.
|
||||
void set_debug_stream (std::ostream &);
|
||||
|
||||
/// Type for debugging levels.
|
||||
typedef int debug_level_type;
|
||||
/// The current debugging level.
|
||||
debug_level_type debug_level () const;
|
||||
/// Set the current debugging level.
|
||||
void set_debug_level (debug_level_type l);
|
||||
|
||||
private:
|
||||
/// Report a syntax error.
|
||||
/// \param loc where the syntax error is found.
|
||||
/// \param msg a description of the syntax error.
|
||||
virtual void error (const location_type& loc, const std::string& msg);
|
||||
|
||||
/// Generate an error message.
|
||||
/// \param state the state where the error occurred.
|
||||
/// \param tok the look-ahead token.
|
||||
virtual std::string yysyntax_error_ (int yystate, int tok);
|
||||
|
||||
#if YYDEBUG
|
||||
/// \brief Report a symbol value on the debug stream.
|
||||
/// \param yytype The token type.
|
||||
/// \param yyvaluep Its semantic value.
|
||||
/// \param yylocationp Its location.
|
||||
virtual void yy_symbol_value_print_ (int yytype,
|
||||
const semantic_type* yyvaluep,
|
||||
const location_type* yylocationp);
|
||||
/// \brief Report a symbol on the debug stream.
|
||||
/// \param yytype The token type.
|
||||
/// \param yyvaluep Its semantic value.
|
||||
/// \param yylocationp Its location.
|
||||
virtual void yy_symbol_print_ (int yytype,
|
||||
const semantic_type* yyvaluep,
|
||||
const location_type* yylocationp);
|
||||
#endif /* ! YYDEBUG */
|
||||
|
||||
|
||||
/// State numbers.
|
||||
typedef int state_type;
|
||||
/// State stack type.
|
||||
typedef stack<state_type> state_stack_type;
|
||||
/// Semantic value stack type.
|
||||
typedef stack<semantic_type> semantic_stack_type;
|
||||
/// location stack type.
|
||||
typedef stack<location_type> location_stack_type;
|
||||
|
||||
/// The state stack.
|
||||
state_stack_type yystate_stack_;
|
||||
/// The semantic value stack.
|
||||
semantic_stack_type yysemantic_stack_;
|
||||
/// The location stack.
|
||||
location_stack_type yylocation_stack_;
|
||||
|
||||
/// Internal symbol numbers.
|
||||
typedef unsigned char token_number_type;
|
||||
/* Tables. */
|
||||
/// For a state, the index in \a yytable_ of its portion.
|
||||
static const short int yypact_[];
|
||||
static const signed char yypact_ninf_;
|
||||
|
||||
/// For a state, default rule to reduce.
|
||||
/// Unless\a yytable_ specifies something else to do.
|
||||
/// Zero means the default is an error.
|
||||
static const unsigned char yydefact_[];
|
||||
|
||||
static const short int yypgoto_[];
|
||||
static const short int yydefgoto_[];
|
||||
|
||||
/// What to do in a state.
|
||||
/// \a yytable_[yypact_[s]]: what to do in state \a s.
|
||||
/// - if positive, shift that token.
|
||||
/// - if negative, reduce the rule which number is the opposite.
|
||||
/// - if zero, do what YYDEFACT says.
|
||||
static const unsigned short int yytable_[];
|
||||
static const signed char yytable_ninf_;
|
||||
|
||||
static const short int yycheck_[];
|
||||
|
||||
/// For a state, its accessing symbol.
|
||||
static const unsigned char yystos_[];
|
||||
|
||||
/// For a rule, its LHS.
|
||||
static const unsigned char yyr1_[];
|
||||
/// For a rule, its RHS length.
|
||||
static const unsigned char yyr2_[];
|
||||
|
||||
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
|
||||
/// For a symbol, its name in clear.
|
||||
static const char* const yytname_[];
|
||||
#endif
|
||||
|
||||
#if YYERROR_VERBOSE
|
||||
/// Convert the symbol name \a n to a form suitable for a diagnostic.
|
||||
virtual std::string yytnamerr_ (const char *n);
|
||||
#endif
|
||||
|
||||
#if YYDEBUG
|
||||
/// A type to store symbol numbers and -1.
|
||||
typedef short int rhs_number_type;
|
||||
/// A `-1'-separated list of the rules' RHS.
|
||||
static const rhs_number_type yyrhs_[];
|
||||
/// For each rule, the index of the first RHS symbol in \a yyrhs_.
|
||||
static const unsigned short int yyprhs_[];
|
||||
/// For each rule, its source line number.
|
||||
static const unsigned short int yyrline_[];
|
||||
/// For each scanner token number, its symbol number.
|
||||
static const unsigned short int yytoken_number_[];
|
||||
/// Report on the debug stream that the rule \a r is going to be reduced.
|
||||
virtual void yy_reduce_print_ (int r);
|
||||
/// Print the state stack on the debug stream.
|
||||
virtual void yystack_print_ ();
|
||||
#endif
|
||||
|
||||
/// Convert a scanner token number \a t to a symbol number.
|
||||
token_number_type yytranslate_ (int t);
|
||||
|
||||
/// \brief Reclaim the memory associated to a symbol.
|
||||
/// \param yymsg Why this token is reclaimed.
|
||||
/// \param yytype The symbol type.
|
||||
/// \param yyvaluep Its semantic value.
|
||||
/// \param yylocationp Its location.
|
||||
inline void yydestruct_ (const char* yymsg,
|
||||
int yytype,
|
||||
semantic_type* yyvaluep,
|
||||
location_type* yylocationp);
|
||||
|
||||
/// Pop \a n symbols the three stacks.
|
||||
inline void yypop_ (unsigned int n = 1);
|
||||
|
||||
/* Constants. */
|
||||
static const int yyeof_;
|
||||
/* LAST_ -- Last index in TABLE_. */
|
||||
static const int yylast_;
|
||||
static const int yynnts_;
|
||||
static const int yyempty_;
|
||||
static const int yyfinal_;
|
||||
static const int yyterror_;
|
||||
static const int yyerrcode_;
|
||||
static const int yyntokens_;
|
||||
static const unsigned int yyuser_token_number_max_;
|
||||
static const token_number_type yyundef_token_;
|
||||
|
||||
/* Debugging. */
|
||||
int yydebug_;
|
||||
std::ostream* yycdebug_;
|
||||
|
||||
|
||||
/* User arguments. */
|
||||
class pgsDriver & driver;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif /* ! defined PARSER_HEADER_H */
|
||||
45
include/pgscript/pgScript.h
Normal file
45
include/pgscript/pgScript.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef PGSNITTEST_H_
|
||||
#define PGSNITTEST_H_
|
||||
|
||||
/*** TYPEDEFS ***/
|
||||
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned short int USHORT;
|
||||
|
||||
/*** DEFINES ***/
|
||||
|
||||
#define pgsReal true
|
||||
#define pgsInt false
|
||||
|
||||
/*** PGADMIN ***/
|
||||
|
||||
#include "pgAdmin3.h"
|
||||
|
||||
/*** INCLUDES ***/
|
||||
|
||||
#if defined(HAVE_CONFIG_H) && defined(PGSCLI)
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
/*** OUTPUT ***/
|
||||
|
||||
#include <wx/txtstrm.h>
|
||||
#define pgsOutputStream wxTextOutputStream
|
||||
|
||||
const wxString PGSOUTPGSCRIPT (wxT("[PGSCRIPT ] "));
|
||||
const wxString PGSOUTEXCEPTION(wxT("[EXCEPTION] "));
|
||||
const wxString PGSOUTQUERY (wxT("[QUERY ] "));
|
||||
const wxString PGSOUTWARNING (wxT("[WARNING ] "));
|
||||
const wxString PGSOUTERROR (wxT("[ERROR ] "));
|
||||
|
||||
/*** LOGGING ***/
|
||||
|
||||
#include "utils/sysLogger.h"
|
||||
|
||||
/*** MEMORY LEAK DETECTION ***/
|
||||
|
||||
#include "pgscript/utilities/pgsAlloc.h"
|
||||
|
||||
#endif /*PGSNITTEST_H_*/
|
||||
128
include/pgscript/pgsApplication.h
Normal file
128
include/pgscript/pgsApplication.h
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSAPP_H_
|
||||
#define PGSAPP_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/utilities/pgsThread.h"
|
||||
|
||||
class pgsApplication
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static const int default_port = 5432;
|
||||
|
||||
private:
|
||||
|
||||
/** Global symbol table shared between different runs. */
|
||||
pgsVarMap m_vars;
|
||||
|
||||
/** In order to have only one thread at once. */
|
||||
wxSemaphore m_mutex;
|
||||
|
||||
/** Protects stream accesses. */
|
||||
wxSemaphore m_stream;
|
||||
|
||||
/** Connection to the database. */
|
||||
pgConn *m_connection;
|
||||
|
||||
/** Is m_connection provided in the constructor or has it been created. */
|
||||
bool m_defined_conn;
|
||||
|
||||
/** Detached thread running a pgScript (parses a file or a string). */
|
||||
pgsThread *m_thread;
|
||||
|
||||
/** pgAdmin specific: post an event to this window when m_thread is done. */
|
||||
wxWindow *m_caller;
|
||||
|
||||
/** pgAdmin specific: post this event when m_thread is done. */
|
||||
long m_event_id;
|
||||
|
||||
/** Location of the last error if there was one. */
|
||||
int m_last_error_line;
|
||||
|
||||
public:
|
||||
|
||||
/** Creates an application and creates a connection. */
|
||||
pgsApplication(const wxString &host, const wxString &database,
|
||||
const wxString &user, const wxString &password, int port = default_port);
|
||||
|
||||
/** Creates an application and uses an existing connection. This connection
|
||||
* is not deleted when the application is deleted. */
|
||||
pgsApplication(pgConn *connection);
|
||||
|
||||
/** Deletes custom connection if one was created (first constructor). */
|
||||
~pgsApplication();
|
||||
|
||||
/** Parses a file by creating a new thread. */
|
||||
bool ParseFile(const wxString &file, pgsOutputStream &out,
|
||||
wxMBConv *conv = &wxConvLocal);
|
||||
|
||||
/** Parses a string by creating a new thread. */
|
||||
bool ParseString(const wxString &string, pgsOutputStream &out);
|
||||
|
||||
/** Is m_thread running? */
|
||||
bool IsRunning();
|
||||
|
||||
/** If m_thread is running then wait for it to terminate. */
|
||||
void Wait();
|
||||
|
||||
/** If m_thread is running then delete it. */
|
||||
void Terminate();
|
||||
|
||||
/** Called by m_thread when the thread is finished: IsRunning() becomes
|
||||
* false and m_event_id is pushed into the event queue if m_caller exists. */
|
||||
void Complete();
|
||||
|
||||
/** Uses a new database connection instead of the previous one. If the
|
||||
* previous one was user-defined then it is deleted otherwise it is just
|
||||
* replaced with the new one. */
|
||||
void SetConnection(pgConn *conn);
|
||||
|
||||
/** Deletes everything in the symbol table. */
|
||||
void ClearSymbols();
|
||||
|
||||
#if !defined(PGSCLI)
|
||||
/** Used in pgAdmin integration for sending an event to the caller when the
|
||||
* thread is finishing its task. */
|
||||
void SetCaller(wxWindow *caller, long event_id);
|
||||
#endif // PGSCLI
|
||||
|
||||
/** Tells whether the database connection is valid. */
|
||||
bool IsConnectionValid() const;
|
||||
|
||||
/** Gets a lock on the output stream. */
|
||||
void LockOutput();
|
||||
|
||||
/** Releases the lock on the output stream. */
|
||||
void UnlockOutput();
|
||||
|
||||
/** Was there an error? */
|
||||
bool errorOccurred() const;
|
||||
|
||||
/** Get the position (line) of the last error. */
|
||||
int errorLine() const;
|
||||
|
||||
private:
|
||||
|
||||
/** Common method for parse_file & parse_string: runs the thread. */
|
||||
bool RunThread();
|
||||
|
||||
private:
|
||||
|
||||
pgsApplication(const pgsApplication &that);
|
||||
|
||||
pgsApplication &operator=(const pgsApplication &that);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSAPP_H_*/
|
||||
142
include/pgscript/position.hh
Normal file
142
include/pgscript/position.hh
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
|
||||
/* Positions for Bison parsers in C++
|
||||
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/**
|
||||
** \file position.hh
|
||||
** Define the pgscript::position class.
|
||||
*/
|
||||
|
||||
#ifndef BISON_POSITION_HH
|
||||
# define BISON_POSITION_HH
|
||||
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
|
||||
namespace pgscript
|
||||
{
|
||||
/// Abstract a position.
|
||||
class position
|
||||
{
|
||||
public:
|
||||
|
||||
/// Construct a position.
|
||||
position ()
|
||||
: filename (0), line (1), column (0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// Initialization.
|
||||
inline void initialize (std::string* fn)
|
||||
{
|
||||
filename = fn;
|
||||
line = 1;
|
||||
column = 0;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
public:
|
||||
/// (line related) Advance to the COUNT next lines.
|
||||
inline void lines (int count = 1)
|
||||
{
|
||||
column = 0;
|
||||
line += count;
|
||||
}
|
||||
|
||||
/// (column related) Advance to the COUNT next columns.
|
||||
inline void columns (int count = 1)
|
||||
{
|
||||
int leftmost = 0;
|
||||
int current = column;
|
||||
if (leftmost <= current + count)
|
||||
column += count;
|
||||
else
|
||||
column = 0;
|
||||
}
|
||||
/** \} */
|
||||
|
||||
public:
|
||||
/// File name to which this position refers.
|
||||
std::string* filename;
|
||||
/// Current line number.
|
||||
unsigned int line;
|
||||
/// Current column number.
|
||||
unsigned int column;
|
||||
};
|
||||
|
||||
/// Add and assign a position.
|
||||
inline const position&
|
||||
operator+= (position& res, const int width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add two position objects.
|
||||
inline const position
|
||||
operator+ (const position& begin, const int width)
|
||||
{
|
||||
position res = begin;
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Add and assign a position.
|
||||
inline const position&
|
||||
operator-= (position& res, const int width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Add two position objects.
|
||||
inline const position
|
||||
operator- (const position& begin, const int width)
|
||||
{
|
||||
return begin + -width;
|
||||
}
|
||||
|
||||
/** \brief Intercept output stream redirection.
|
||||
** \param ostr the destination output stream
|
||||
** \param pos a reference to the position to redirect
|
||||
*/
|
||||
inline std::ostream&
|
||||
operator<< (std::ostream& ostr, const position& pos)
|
||||
{
|
||||
if (pos.filename)
|
||||
ostr << *pos.filename << ':';
|
||||
return ostr << pos.line << '.' << pos.column;
|
||||
}
|
||||
|
||||
}
|
||||
#endif // not BISON_POSITION_HH
|
||||
152
include/pgscript/stack.hh
Normal file
152
include/pgscript/stack.hh
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
|
||||
/* Stack handling for Bison parsers in C++
|
||||
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
#ifndef BISON_STACK_HH
|
||||
# define BISON_STACK_HH
|
||||
|
||||
/* The Sun compiler defines _T, which conflicts with wxWidgets, so
|
||||
we must un-define it if needed. */
|
||||
#if defined(__SUNPRO_CC)
|
||||
#ifdef _T
|
||||
#undef _T
|
||||
#define _T_is_defined
|
||||
#endif
|
||||
#endif /*__SUNPRO_CC */
|
||||
|
||||
#include <deque>
|
||||
|
||||
namespace pgscript
|
||||
{
|
||||
template <class T, class S = std::deque<T> >
|
||||
class stack
|
||||
{
|
||||
public:
|
||||
|
||||
// Hide our reversed order.
|
||||
typedef typename S::reverse_iterator iterator;
|
||||
typedef typename S::const_reverse_iterator const_iterator;
|
||||
|
||||
stack () : seq_ ()
|
||||
{
|
||||
}
|
||||
|
||||
stack (unsigned int n) : seq_ (n)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
T&
|
||||
operator [] (unsigned int i)
|
||||
{
|
||||
return seq_[i];
|
||||
}
|
||||
|
||||
inline
|
||||
const T&
|
||||
operator [] (unsigned int i) const
|
||||
{
|
||||
return seq_[i];
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
push (const T& t)
|
||||
{
|
||||
seq_.push_front (t);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
pop (unsigned int n = 1)
|
||||
{
|
||||
for (; n; --n)
|
||||
seq_.pop_front ();
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned int
|
||||
height () const
|
||||
{
|
||||
return seq_.size ();
|
||||
}
|
||||
|
||||
inline const_iterator begin () const { return seq_.rbegin (); }
|
||||
inline const_iterator end () const { return seq_.rend (); }
|
||||
|
||||
private:
|
||||
|
||||
S seq_;
|
||||
};
|
||||
|
||||
/// Present a slice of the top of a stack.
|
||||
template <class T, class S = stack<T> >
|
||||
class slice
|
||||
{
|
||||
public:
|
||||
|
||||
slice (const S& stack,
|
||||
unsigned int range) : stack_ (stack),
|
||||
range_ (range)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
const T&
|
||||
operator [] (unsigned int i) const
|
||||
{
|
||||
return stack_[range_ - i];
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const S& stack_;
|
||||
unsigned int range_;
|
||||
};
|
||||
}
|
||||
|
||||
/* Redefine _T if we un-defined it for the Sun compiler. */
|
||||
#if defined(__SUNPRO_CC)
|
||||
#ifdef _T_is_defined
|
||||
#undef _T_is_defined
|
||||
/* we need to define it back only if _T already was defined. */
|
||||
#if !wxUSE_UNICODE
|
||||
#define _T(x) x
|
||||
#else /* Unicode */
|
||||
/* use wxCONCAT_HELPER so that x could be expanded if it's a macro */
|
||||
#define _T(x) wxCONCAT_HELPER(L, x)
|
||||
#endif /* ASCII/Unicode */
|
||||
#endif /* T_is_defined */
|
||||
#endif /*__SUNPRO_CC */
|
||||
|
||||
#endif // not BISON_STACK_HH
|
||||
28
include/pgscript/statements/module.mk
Normal file
28
include/pgscript/statements/module.mk
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#######################################################################
|
||||
#
|
||||
# pgAdmin III - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
# module.mk - pgadmin/include/pgscript/statements/ Makefile fragment
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
pgadmin3_SOURCES += \
|
||||
include/pgscript/statements/pgsAssertStmt.h \
|
||||
include/pgscript/statements/pgsBreakStmt.h \
|
||||
include/pgscript/statements/pgsContinueStmt.h \
|
||||
include/pgscript/statements/pgsDeclareRecordStmt.h \
|
||||
include/pgscript/statements/pgsExpressionStmt.h \
|
||||
include/pgscript/statements/pgsIfStmt.h \
|
||||
include/pgscript/statements/pgsPrintStmt.h \
|
||||
include/pgscript/statements/pgsProgram.h \
|
||||
include/pgscript/statements/pgsStatements.h \
|
||||
include/pgscript/statements/pgsStmt.h \
|
||||
include/pgscript/statements/pgsStmtList.h \
|
||||
include/pgscript/statements/pgsWhileStmt.h
|
||||
|
||||
EXTRA_DIST += \
|
||||
include/pgscript/statements/module.mk
|
||||
|
||||
40
include/pgscript/statements/pgsAssertStmt.h
Normal file
40
include/pgscript/statements/pgsAssertStmt.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSASSERTSTMT_H_
|
||||
#define PGSASSERTSTMT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/statements/pgsStmt.h"
|
||||
|
||||
class pgsAssertStmt : public pgsStmt
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_cond;
|
||||
|
||||
public:
|
||||
|
||||
pgsAssertStmt(const pgsExpression *cond, pgsThread *app = 0);
|
||||
|
||||
virtual ~pgsAssertStmt();
|
||||
|
||||
virtual void eval(pgsVarMap &vars) const;
|
||||
|
||||
private:
|
||||
|
||||
pgsAssertStmt(const pgsAssertStmt &that);
|
||||
|
||||
pgsAssertStmt &operator=(const pgsAssertStmt &that);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSASSERTSTMT_H_*/
|
||||
36
include/pgscript/statements/pgsBreakStmt.h
Normal file
36
include/pgscript/statements/pgsBreakStmt.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSBREAKSTMT_H_
|
||||
#define PGSBREAKSTMT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/statements/pgsStmt.h"
|
||||
|
||||
class pgsBreakStmt : public pgsStmt
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsBreakStmt(pgsThread *app = 0);
|
||||
|
||||
virtual ~pgsBreakStmt();
|
||||
|
||||
virtual void eval(pgsVarMap &vars) const;
|
||||
|
||||
private:
|
||||
|
||||
pgsBreakStmt(const pgsBreakStmt &that);
|
||||
|
||||
pgsBreakStmt &operator=(const pgsBreakStmt &that);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSBREAKSTMT_H_*/
|
||||
36
include/pgscript/statements/pgsContinueStmt.h
Normal file
36
include/pgscript/statements/pgsContinueStmt.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSCONTINUESTMT_H_
|
||||
#define PGSCONTINUESTMT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/statements/pgsStmt.h"
|
||||
|
||||
class pgsContinueStmt : public pgsStmt
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pgsContinueStmt(pgsThread *app = 0);
|
||||
|
||||
virtual ~pgsContinueStmt();
|
||||
|
||||
virtual void eval(pgsVarMap &vars) const;
|
||||
|
||||
private:
|
||||
|
||||
pgsContinueStmt(const pgsContinueStmt &that);
|
||||
|
||||
pgsContinueStmt &operator=(const pgsContinueStmt &that);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSCONTINUESTMT_H_*/
|
||||
42
include/pgscript/statements/pgsDeclareRecordStmt.h
Normal file
42
include/pgscript/statements/pgsDeclareRecordStmt.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSDECLARERECORDSTMT_H_
|
||||
#define PGSDECLARERECORDSTMT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/statements/pgsStmt.h"
|
||||
|
||||
class pgsDeclareRecordStmt : public pgsStmt
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const wxString m_rec;
|
||||
const wxArrayString m_columns;
|
||||
|
||||
public:
|
||||
|
||||
pgsDeclareRecordStmt(const wxString &rec,
|
||||
const wxArrayString &columns, pgsThread *app = 0);
|
||||
|
||||
virtual ~pgsDeclareRecordStmt();
|
||||
|
||||
virtual void eval(pgsVarMap &vars) const;
|
||||
|
||||
private:
|
||||
|
||||
pgsDeclareRecordStmt(const pgsDeclareRecordStmt &that);
|
||||
|
||||
pgsDeclareRecordStmt &operator=(const pgsDeclareRecordStmt &that);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSDECLARERECORDSTMT_H_*/
|
||||
40
include/pgscript/statements/pgsExpressionStmt.h
Normal file
40
include/pgscript/statements/pgsExpressionStmt.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSEXPRESSIONSTMT_H_
|
||||
#define PGSEXPRESSIONSTMT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/statements/pgsStmt.h"
|
||||
|
||||
class pgsExpressionStmt : public pgsStmt
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_var;
|
||||
|
||||
public:
|
||||
|
||||
pgsExpressionStmt(const pgsExpression *var, pgsThread *app = 0);
|
||||
|
||||
virtual ~pgsExpressionStmt();
|
||||
|
||||
virtual void eval(pgsVarMap &vars) const;
|
||||
|
||||
private:
|
||||
|
||||
pgsExpressionStmt(const pgsExpressionStmt &that);
|
||||
|
||||
pgsExpressionStmt &operator=(const pgsExpressionStmt &that);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSEXPRESSIONSTMT_H_*/
|
||||
43
include/pgscript/statements/pgsIfStmt.h
Normal file
43
include/pgscript/statements/pgsIfStmt.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSIFSTMT_H_
|
||||
#define PGSIFSTMT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/statements/pgsStmt.h"
|
||||
|
||||
class pgsIfStmt : public pgsStmt
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_cond;
|
||||
const pgsStmt *m_stmt_list_if;
|
||||
const pgsStmt *m_stmt_list_else;
|
||||
|
||||
public:
|
||||
|
||||
pgsIfStmt(const pgsExpression *cond, const pgsStmt *stmt_list_if,
|
||||
const pgsStmt *stmt_list_else, pgsThread *app = 0);
|
||||
|
||||
virtual ~pgsIfStmt();
|
||||
|
||||
virtual void eval(pgsVarMap &vars) const;
|
||||
|
||||
private:
|
||||
|
||||
pgsIfStmt(const pgsIfStmt &that);
|
||||
|
||||
pgsIfStmt &operator=(const pgsIfStmt &that);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSIFSTMT_H_*/
|
||||
43
include/pgscript/statements/pgsPrintStmt.h
Normal file
43
include/pgscript/statements/pgsPrintStmt.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSPRINTSTMT_H_
|
||||
#define PGSPRINTSTMT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/statements/pgsStmt.h"
|
||||
|
||||
class pgsPrintStmt : public pgsStmt
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_var;
|
||||
|
||||
pgsOutputStream &m_cout;
|
||||
|
||||
public:
|
||||
|
||||
pgsPrintStmt(const pgsExpression *var, pgsOutputStream &cout,
|
||||
pgsThread *app = 0);
|
||||
|
||||
virtual ~pgsPrintStmt();
|
||||
|
||||
virtual void eval(pgsVarMap &vars) const;
|
||||
|
||||
private:
|
||||
|
||||
pgsPrintStmt(const pgsPrintStmt &that);
|
||||
|
||||
pgsPrintStmt &operator=(const pgsPrintStmt &that);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSPRINTSTMT_H_*/
|
||||
48
include/pgscript/statements/pgsProgram.h
Normal file
48
include/pgscript/statements/pgsProgram.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSPROGRAM_H_
|
||||
#define PGSPROGRAM_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/objects/pgsVariable.h"
|
||||
|
||||
#include <wx/thread.h>
|
||||
|
||||
class pgsStmtList;
|
||||
|
||||
class pgsProgram
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
pgsVarMap &m_vars;
|
||||
|
||||
public:
|
||||
|
||||
pgsProgram(pgsVarMap &vars);
|
||||
|
||||
~pgsProgram();
|
||||
|
||||
void dump();
|
||||
|
||||
static void dump(const pgsVarMap &vars);
|
||||
|
||||
void eval(pgsStmtList *stmt_list);
|
||||
|
||||
private:
|
||||
|
||||
pgsProgram(const pgsProgram &that);
|
||||
|
||||
pgsProgram &operator=(const pgsProgram &that);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSPROGRAM_H_*/
|
||||
26
include/pgscript/statements/pgsStatements.h
Normal file
26
include/pgscript/statements/pgsStatements.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSSTATEMENTS_H_
|
||||
#define PGSSTATEMENTS_H_
|
||||
|
||||
#include "pgsAssertStmt.h"
|
||||
#include "pgsBreakStmt.h"
|
||||
#include "pgsContinueStmt.h"
|
||||
#include "pgsDeclareRecordStmt.h"
|
||||
#include "pgsExpressionStmt.h"
|
||||
#include "pgsIfStmt.h"
|
||||
#include "pgsPrintStmt.h"
|
||||
#include "pgsProgram.h"
|
||||
#include "pgsStmt.h"
|
||||
#include "pgsStmtList.h"
|
||||
#include "pgsWhileStmt.h"
|
||||
|
||||
#endif /*PGSSTATEMENTS_H_*/
|
||||
50
include/pgscript/statements/pgsStmt.h
Normal file
50
include/pgscript/statements/pgsStmt.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSSTMT_H_
|
||||
#define PGSSTMT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/objects/pgsVariable.h"
|
||||
|
||||
class pgsThread;
|
||||
|
||||
class pgsStmt
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
unsigned int m_line;
|
||||
|
||||
protected:
|
||||
|
||||
pgsThread *m_app;
|
||||
|
||||
public:
|
||||
|
||||
pgsStmt(pgsThread *app = 0);
|
||||
|
||||
virtual ~pgsStmt();
|
||||
|
||||
void set_position(int line);
|
||||
|
||||
int line() const;
|
||||
|
||||
virtual void eval(pgsVarMap &vars) const = 0;
|
||||
|
||||
private:
|
||||
|
||||
pgsStmt(const pgsStmt &that);
|
||||
|
||||
pgsStmt &operator=(const pgsStmt &that);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSSTMT_H_*/
|
||||
52
include/pgscript/statements/pgsStmtList.h
Normal file
52
include/pgscript/statements/pgsStmtList.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSSTMTLIST_H_
|
||||
#define PGSSTMTLIST_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/statements/pgsStmt.h"
|
||||
|
||||
WX_DECLARE_LIST(pgsStmt, pgsListStmt);
|
||||
|
||||
class pgsStmtList : public pgsStmt
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
pgsListStmt m_stmt_list;
|
||||
|
||||
pgsOutputStream &m_cout;
|
||||
|
||||
public:
|
||||
|
||||
static bool m_exception_thrown;
|
||||
|
||||
public:
|
||||
|
||||
pgsStmtList(pgsOutputStream &cout, pgsThread *app = 0);
|
||||
|
||||
virtual ~pgsStmtList();
|
||||
|
||||
virtual void eval(pgsVarMap &vars) const;
|
||||
|
||||
void insert_front(pgsStmt *stmt);
|
||||
|
||||
void insert_back(pgsStmt *stmt);
|
||||
|
||||
private:
|
||||
|
||||
pgsStmtList(const pgsStmtList &that);
|
||||
|
||||
pgsStmtList &operator=(const pgsStmtList &that);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSSTMTLIST_H_*/
|
||||
42
include/pgscript/statements/pgsWhileStmt.h
Normal file
42
include/pgscript/statements/pgsWhileStmt.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSWHILESTMT_H_
|
||||
#define PGSWHILESTMT_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/statements/pgsStmt.h"
|
||||
|
||||
class pgsWhileStmt : public pgsStmt
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
const pgsExpression *m_cond;
|
||||
const pgsStmt *m_stmt_list;
|
||||
|
||||
public:
|
||||
|
||||
pgsWhileStmt(const pgsExpression *cond, const pgsStmt *stmt_list,
|
||||
pgsThread *app = 0);
|
||||
|
||||
virtual ~pgsWhileStmt();
|
||||
|
||||
virtual void eval(pgsVarMap &vars) const;
|
||||
|
||||
private:
|
||||
|
||||
pgsWhileStmt(const pgsWhileStmt &that);
|
||||
|
||||
pgsWhileStmt &operator=(const pgsWhileStmt &that);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSWHILESTMT_H_*/
|
||||
13
include/pgscript/utilities/mapm-lib/license.txt
Normal file
13
include/pgscript/utilities/mapm-lib/license.txt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
/*
|
||||
* THIS FILE HAS BEEN MODIFIED FROM THE OFFICIAL MAPM DISTRIBUTION
|
||||
* BY 'Mickael Deloison/pgScript' on 2008/02/26.
|
||||
*
|
||||
* THIS FILE IS ORIGINALLY FROM MAPM VERSION 4.9.5.
|
||||
*
|
||||
* .... OPTIONAL: a brief description of file changes here ....
|
||||
*/
|
||||
|
||||
... start of MAPM original file ...
|
||||
|
||||
|
||||
767
include/pgscript/utilities/mapm-lib/m_apm.h
Normal file
767
include/pgscript/utilities/mapm-lib/m_apm.h
Normal file
|
|
@ -0,0 +1,767 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* M_APM - m_apm.h
|
||||
*
|
||||
* Copyright (C) 1999 - 2007 Michael C. Ring
|
||||
*
|
||||
* Permission to use, copy, and distribute this software and its
|
||||
* documentation for any purpose with or without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation.
|
||||
*
|
||||
* Permission to modify the software is granted. Permission to distribute
|
||||
* the modified code is granted. Modifications are to be distributed by
|
||||
* using the file 'license.txt' as a template to modify the file header.
|
||||
* 'license.txt' is available in the official MAPM distribution.
|
||||
*
|
||||
* This software is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is the header file that the user will include.
|
||||
*
|
||||
*/
|
||||
|
||||
#undef sprintf
|
||||
#undef strcat
|
||||
|
||||
#ifndef M__APM__INCLUDED
|
||||
#define M__APM__INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* Comment this line out if you've compiled the library as C++. */
|
||||
#define APM_CONVERT_FROM_C
|
||||
#endif
|
||||
|
||||
#ifdef APM_CONVERT_FROM_C
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned char UCHAR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UCHAR *m_apm_data;
|
||||
long m_apm_id;
|
||||
int m_apm_refcount; /* <- used only by C++ MAPM class */
|
||||
int m_apm_malloclength;
|
||||
int m_apm_datalength;
|
||||
int m_apm_exponent;
|
||||
int m_apm_sign;
|
||||
} M_APM_struct;
|
||||
|
||||
typedef M_APM_struct *M_APM;
|
||||
|
||||
|
||||
#define MAPM_LIB_VERSION \
|
||||
"MAPM Library Version 4.9.5 Copyright (C) 1999-2007, Michael C. Ring"
|
||||
#define MAPM_LIB_SHORT_VERSION "4.9.5"
|
||||
|
||||
|
||||
/*
|
||||
* convienient predefined constants
|
||||
*/
|
||||
|
||||
extern M_APM MM_Zero;
|
||||
extern M_APM MM_One;
|
||||
extern M_APM MM_Two;
|
||||
extern M_APM MM_Three;
|
||||
extern M_APM MM_Four;
|
||||
extern M_APM MM_Five;
|
||||
extern M_APM MM_Ten;
|
||||
|
||||
extern M_APM MM_PI;
|
||||
extern M_APM MM_HALF_PI;
|
||||
extern M_APM MM_2_PI;
|
||||
extern M_APM MM_E;
|
||||
|
||||
extern M_APM MM_LOG_E_BASE_10;
|
||||
extern M_APM MM_LOG_10_BASE_E;
|
||||
extern M_APM MM_LOG_2_BASE_E;
|
||||
extern M_APM MM_LOG_3_BASE_E;
|
||||
|
||||
|
||||
/*
|
||||
* function prototypes
|
||||
*/
|
||||
|
||||
extern M_APM m_apm_init(void);
|
||||
extern void m_apm_free(M_APM);
|
||||
extern void m_apm_free_all_mem(void);
|
||||
extern void m_apm_trim_mem_usage(void);
|
||||
extern char *m_apm_lib_version(char *);
|
||||
extern char *m_apm_lib_short_version(char *);
|
||||
|
||||
extern void m_apm_set_string(M_APM, const char *);
|
||||
extern void m_apm_set_double(M_APM, double);
|
||||
extern void m_apm_set_long(M_APM, long);
|
||||
|
||||
extern void m_apm_to_string(char *, int, M_APM);
|
||||
extern void m_apm_to_fixpt_string(char *, int, M_APM);
|
||||
extern void m_apm_to_fixpt_stringex(char *, int, M_APM, char, char, int);
|
||||
extern char *m_apm_to_fixpt_stringexp(int, M_APM, char, char, int);
|
||||
extern void m_apm_to_integer_string(char *, M_APM);
|
||||
|
||||
extern void m_apm_absolute_value(M_APM, M_APM);
|
||||
extern void m_apm_negate(M_APM, M_APM);
|
||||
extern void m_apm_copy(M_APM, M_APM);
|
||||
extern void m_apm_round(M_APM, int, M_APM);
|
||||
extern int m_apm_compare(M_APM, M_APM);
|
||||
extern int m_apm_sign(M_APM);
|
||||
extern int m_apm_exponent(M_APM);
|
||||
extern int m_apm_significant_digits(M_APM);
|
||||
extern int m_apm_is_integer(M_APM);
|
||||
extern int m_apm_is_even(M_APM);
|
||||
extern int m_apm_is_odd(M_APM);
|
||||
|
||||
extern void m_apm_gcd(M_APM, M_APM, M_APM);
|
||||
extern void m_apm_lcm(M_APM, M_APM, M_APM);
|
||||
|
||||
extern void m_apm_add(M_APM, M_APM, M_APM);
|
||||
extern void m_apm_subtract(M_APM, M_APM, M_APM);
|
||||
extern void m_apm_multiply(M_APM, M_APM, M_APM);
|
||||
extern void m_apm_divide(M_APM, int, M_APM, M_APM);
|
||||
extern void m_apm_integer_divide(M_APM, M_APM, M_APM);
|
||||
extern void m_apm_integer_div_rem(M_APM, M_APM, M_APM, M_APM);
|
||||
extern void m_apm_reciprocal(M_APM, int, M_APM);
|
||||
extern void m_apm_factorial(M_APM, M_APM);
|
||||
extern void m_apm_floor(M_APM, M_APM);
|
||||
extern void m_apm_ceil(M_APM, M_APM);
|
||||
extern void m_apm_get_random(M_APM);
|
||||
extern void m_apm_set_random_seed(char *);
|
||||
|
||||
extern void m_apm_sqrt(M_APM, int, M_APM);
|
||||
extern void m_apm_cbrt(M_APM, int, M_APM);
|
||||
extern void m_apm_log(M_APM, int, M_APM);
|
||||
extern void m_apm_log10(M_APM, int, M_APM);
|
||||
extern void m_apm_exp(M_APM, int, M_APM);
|
||||
extern void m_apm_pow(M_APM, int, M_APM, M_APM);
|
||||
extern void m_apm_integer_pow(M_APM, int, M_APM, int);
|
||||
extern void m_apm_integer_pow_nr(M_APM, M_APM, int);
|
||||
|
||||
extern void m_apm_sin_cos(M_APM, M_APM, int, M_APM);
|
||||
extern void m_apm_sin(M_APM, int, M_APM);
|
||||
extern void m_apm_cos(M_APM, int, M_APM);
|
||||
extern void m_apm_tan(M_APM, int, M_APM);
|
||||
extern void m_apm_arcsin(M_APM, int, M_APM);
|
||||
extern void m_apm_arccos(M_APM, int, M_APM);
|
||||
extern void m_apm_arctan(M_APM, int, M_APM);
|
||||
extern void m_apm_arctan2(M_APM, int, M_APM, M_APM);
|
||||
|
||||
extern void m_apm_sinh(M_APM, int, M_APM);
|
||||
extern void m_apm_cosh(M_APM, int, M_APM);
|
||||
extern void m_apm_tanh(M_APM, int, M_APM);
|
||||
extern void m_apm_arcsinh(M_APM, int, M_APM);
|
||||
extern void m_apm_arccosh(M_APM, int, M_APM);
|
||||
extern void m_apm_arctanh(M_APM, int, M_APM);
|
||||
|
||||
extern void m_apm_cpp_precision(int); /* only for C++ wrapper */
|
||||
|
||||
/* more intuitive alternate names for the ARC functions ... */
|
||||
|
||||
#define m_apm_asin m_apm_arcsin
|
||||
#define m_apm_acos m_apm_arccos
|
||||
#define m_apm_atan m_apm_arctan
|
||||
#define m_apm_atan2 m_apm_arctan2
|
||||
|
||||
#define m_apm_asinh m_apm_arcsinh
|
||||
#define m_apm_acosh m_apm_arccosh
|
||||
#define m_apm_atanh m_apm_arctanh
|
||||
|
||||
#ifdef APM_CONVERT_FROM_C
|
||||
} /* End extern "C" bracket */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus /*<- Hides the class below from C compilers */
|
||||
|
||||
/*
|
||||
This class lets you use M_APM's a bit more intuitively with
|
||||
C++'s operator and function overloading, constructors, etc.
|
||||
|
||||
Added 3/24/2000 by Orion Sky Lawlor, olawlor@acm.org
|
||||
*/
|
||||
|
||||
extern
|
||||
#ifdef APM_CONVERT_FROM_C
|
||||
"C"
|
||||
#endif
|
||||
int MM_cpp_min_precision;
|
||||
|
||||
|
||||
class MAPM
|
||||
{
|
||||
protected:
|
||||
|
||||
/*
|
||||
The M_APM structure here is implemented as a reference-
|
||||
counted, copy-on-write data structure-- this makes copies
|
||||
very fast, but that's why it's so ugly. A MAPM object is
|
||||
basically just a wrapper around a (possibly shared)
|
||||
M_APM_struct myVal.
|
||||
*/
|
||||
|
||||
|
||||
M_APM myVal; /* My M_APM structure */
|
||||
void create(void)
|
||||
{
|
||||
myVal = makeNew();
|
||||
}
|
||||
void destroy(void)
|
||||
{
|
||||
unref(myVal);
|
||||
myVal = NULL;
|
||||
}
|
||||
void copyFrom(M_APM Nval)
|
||||
{
|
||||
M_APM oldVal = myVal;
|
||||
myVal = Nval;
|
||||
ref(myVal);
|
||||
unref(oldVal);
|
||||
}
|
||||
static M_APM makeNew(void)
|
||||
{
|
||||
M_APM val = m_apm_init();
|
||||
/* refcount initialized to 1 by 'm_apm_init' */
|
||||
return val;
|
||||
}
|
||||
static void ref(M_APM val)
|
||||
{
|
||||
val->m_apm_refcount++;
|
||||
}
|
||||
static void unref(M_APM val)
|
||||
{
|
||||
val->m_apm_refcount--;
|
||||
if (val->m_apm_refcount == 0)
|
||||
m_apm_free(val);
|
||||
}
|
||||
|
||||
/* This routine is called to get a private (mutable)
|
||||
copy of our current value. */
|
||||
M_APM val(void)
|
||||
{
|
||||
if (myVal->m_apm_refcount == 1)
|
||||
/* Return my private myVal */
|
||||
return myVal;
|
||||
|
||||
/* Otherwise, our copy of myVal is shared--
|
||||
we need to make a new private copy.
|
||||
*/
|
||||
M_APM oldVal = myVal;
|
||||
myVal = makeNew();
|
||||
m_apm_copy(myVal, oldVal);
|
||||
unref(oldVal);
|
||||
return myVal;
|
||||
}
|
||||
|
||||
/*BAD: C M_APM routines doesn't use "const" where they should--
|
||||
hence we have to cast to a non-const type here (FIX THIS!).
|
||||
|
||||
(in due time.... MCR)
|
||||
*/
|
||||
M_APM cval(void) const
|
||||
{
|
||||
return (M_APM)myVal;
|
||||
}
|
||||
/* This is the default number of digits to use for
|
||||
1-ary functions like sin, cos, tan, etc.
|
||||
It's the larger of my digits and cpp_min_precision.
|
||||
*/
|
||||
int myDigits(void) const
|
||||
{
|
||||
int maxd = m_apm_significant_digits(cval());
|
||||
if (maxd < MM_cpp_min_precision) maxd = MM_cpp_min_precision;
|
||||
return maxd;
|
||||
}
|
||||
/* This is the default number of digits to use for
|
||||
2-ary functions like divide, atan2, etc.
|
||||
It's the larger of my digits, his digits, and cpp_min_precision.
|
||||
*/
|
||||
int digits(const MAPM &otherVal) const
|
||||
{
|
||||
int maxd = myDigits();
|
||||
int his = m_apm_significant_digits(otherVal.cval());
|
||||
if (maxd < his) maxd = his;
|
||||
return maxd;
|
||||
}
|
||||
public:
|
||||
/* Constructors: */
|
||||
MAPM(void) /* Default constructor (takes no value) */
|
||||
{
|
||||
create();
|
||||
}
|
||||
MAPM(const MAPM &m) /* Copy constructor */
|
||||
{
|
||||
myVal = (M_APM)m.cval();
|
||||
ref(myVal);
|
||||
}
|
||||
MAPM(M_APM m) /* M_APM constructor (refcount starts at one) */
|
||||
{
|
||||
myVal = (M_APM)m;
|
||||
ref(myVal);
|
||||
}
|
||||
MAPM(const char *s) /* Constructor from string */
|
||||
{
|
||||
create();
|
||||
m_apm_set_string(val(), (char *)s);
|
||||
}
|
||||
MAPM(double d) /* Constructor from double-precision float */
|
||||
{
|
||||
create();
|
||||
m_apm_set_double(val(), d);
|
||||
}
|
||||
MAPM(int l) /* Constructor from int */
|
||||
{
|
||||
create();
|
||||
m_apm_set_long(val(), l);
|
||||
}
|
||||
MAPM(long l) /* Constructor from long int */
|
||||
{
|
||||
create();
|
||||
m_apm_set_long(val(), l);
|
||||
}
|
||||
/* Destructor */
|
||||
~MAPM()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
/* Extracting string descriptions: */
|
||||
void toString(char *dest, int decimalPlaces) const
|
||||
{
|
||||
m_apm_to_string(dest, decimalPlaces, cval());
|
||||
}
|
||||
void toFixPtString(char *dest, int decimalPlaces) const
|
||||
{
|
||||
m_apm_to_fixpt_string(dest, decimalPlaces, cval());
|
||||
}
|
||||
void toFixPtStringEx(char *dest, int dp, char a, char b, int c) const
|
||||
{
|
||||
m_apm_to_fixpt_stringex(dest, dp, cval(), a, b, c);
|
||||
}
|
||||
char *toFixPtStringExp(int dp, char a, char b, int c) const
|
||||
{
|
||||
return(m_apm_to_fixpt_stringexp(dp, cval(), a, b, c));
|
||||
}
|
||||
void toIntegerString(char *dest) const
|
||||
{
|
||||
m_apm_to_integer_string(dest, cval());
|
||||
}
|
||||
|
||||
/* Basic operators: */
|
||||
MAPM &operator=(const MAPM &m) /* Assigment operator */
|
||||
{
|
||||
copyFrom((M_APM)m.cval());
|
||||
return *this;
|
||||
}
|
||||
MAPM &operator=(const char *s) /* Assigment operator */
|
||||
{
|
||||
m_apm_set_string(val(), (char *)s);
|
||||
return *this;
|
||||
}
|
||||
MAPM &operator=(double d) /* Assigment operator */
|
||||
{
|
||||
m_apm_set_double(val(), d);
|
||||
return *this;
|
||||
}
|
||||
MAPM &operator=(int l) /* Assigment operator */
|
||||
{
|
||||
m_apm_set_long(val(), l);
|
||||
return *this;
|
||||
}
|
||||
MAPM &operator=(long l) /* Assigment operator */
|
||||
{
|
||||
m_apm_set_long(val(), l);
|
||||
return *this;
|
||||
}
|
||||
MAPM operator++() /* Prefix increment operator */
|
||||
{
|
||||
return *this = *this + MM_One;
|
||||
}
|
||||
MAPM operator--() /* Prefix decrement operator */
|
||||
{
|
||||
return *this = *this - MM_One;
|
||||
}
|
||||
const MAPM operator++(int) /* Postfix increment operator */
|
||||
{
|
||||
MAPM old = *this;
|
||||
++(*this); /* Call prefix increment */
|
||||
return old;
|
||||
}
|
||||
const MAPM operator--(int) /* Postfix decrement operator */
|
||||
{
|
||||
MAPM old = *this;
|
||||
--(*this); /* Call prefix decrement */
|
||||
return old;
|
||||
}
|
||||
|
||||
/* Comparison operators */
|
||||
int operator==(const MAPM &m) const /* Equality operator */
|
||||
{
|
||||
return m_apm_compare(cval(), m.cval()) == 0;
|
||||
}
|
||||
int operator!=(const MAPM &m) const /* Inequality operator */
|
||||
{
|
||||
return m_apm_compare(cval(), m.cval()) != 0;
|
||||
}
|
||||
int operator<(const MAPM &m) const
|
||||
{
|
||||
return m_apm_compare(cval(), m.cval()) < 0;
|
||||
}
|
||||
int operator<=(const MAPM &m) const
|
||||
{
|
||||
return m_apm_compare(cval(), m.cval()) <= 0;
|
||||
}
|
||||
int operator>(const MAPM &m) const
|
||||
{
|
||||
return m_apm_compare(cval(), m.cval()) > 0;
|
||||
}
|
||||
int operator>=(const MAPM &m) const
|
||||
{
|
||||
return m_apm_compare(cval(), m.cval()) >= 0;
|
||||
}
|
||||
|
||||
/* Basic arithmetic operators */
|
||||
friend MAPM operator+(const MAPM &a, const MAPM &b);
|
||||
friend MAPM operator-(const MAPM &a, const MAPM &b);
|
||||
friend MAPM operator*(const MAPM &a, const MAPM &b)
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_multiply(ret.val(), a.cval(), b.cval());
|
||||
return ret;
|
||||
}
|
||||
friend MAPM operator%(const MAPM &a, const MAPM &b)
|
||||
{
|
||||
MAPM quot, ret;
|
||||
m_apm_integer_div_rem(quot.val(), ret.val(),
|
||||
a.cval(), b.cval());
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Default division keeps larger of cpp_min_precision, numerator
|
||||
digits of precision, or denominator digits of precision. */
|
||||
friend MAPM operator/(const MAPM &a, const MAPM &b)
|
||||
{
|
||||
return a.divide(b, a.digits(b));
|
||||
}
|
||||
|
||||
MAPM divide(const MAPM &m, int toDigits) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_divide(ret.val(), toDigits, cval(),
|
||||
m.cval());
|
||||
return ret;
|
||||
}
|
||||
MAPM divide(const MAPM &m) const
|
||||
{
|
||||
return divide(m, digits(m));
|
||||
}
|
||||
|
||||
/* Assignment arithmetic operators */
|
||||
MAPM &operator+=(const MAPM &m)
|
||||
{
|
||||
*this = *this + m;
|
||||
return *this;
|
||||
}
|
||||
MAPM &operator-=(const MAPM &m)
|
||||
{
|
||||
*this = *this - m;
|
||||
return *this;
|
||||
}
|
||||
MAPM &operator*=(const MAPM &m)
|
||||
{
|
||||
*this = *this * m;
|
||||
return *this;
|
||||
}
|
||||
MAPM &operator/=(const MAPM &m)
|
||||
{
|
||||
*this = *this / m;
|
||||
return *this;
|
||||
}
|
||||
MAPM &operator%=(const MAPM &m)
|
||||
{
|
||||
*this = *this % m;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* Extracting/setting simple information: */
|
||||
int sign(void) const
|
||||
{
|
||||
return m_apm_sign(cval());
|
||||
}
|
||||
int exponent(void) const
|
||||
{
|
||||
return m_apm_exponent(cval());
|
||||
}
|
||||
int significant_digits(void) const
|
||||
{
|
||||
return m_apm_significant_digits(cval());
|
||||
}
|
||||
int is_integer(void) const
|
||||
{
|
||||
return m_apm_is_integer(cval());
|
||||
}
|
||||
int is_even(void) const
|
||||
{
|
||||
return m_apm_is_even(cval());
|
||||
}
|
||||
int is_odd(void) const
|
||||
{
|
||||
return m_apm_is_odd(cval());
|
||||
}
|
||||
|
||||
/* Functions: */
|
||||
MAPM abs(void) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_absolute_value(ret.val(), cval());
|
||||
return ret;
|
||||
}
|
||||
MAPM neg(void) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_negate(ret.val(), cval());
|
||||
return ret;
|
||||
}
|
||||
MAPM round(int toDigits) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_round(ret.val(), toDigits, cval());
|
||||
return ret;
|
||||
}
|
||||
MAPM operator-(void) const
|
||||
{
|
||||
return neg();
|
||||
}
|
||||
|
||||
/* I got tired of typing the various declarations for a simple
|
||||
1-ary real-to-real function on MAPM's; hence this define:
|
||||
The digits-free versions return my digits of precision or
|
||||
cpp_min_precision, whichever is bigger.
|
||||
*/
|
||||
|
||||
#define MAPM_1aryFunc(func) \
|
||||
MAPM func(int toDigits) const\
|
||||
{MAPM ret;m_apm_##func(ret.val(),toDigits,cval());return ret;}\
|
||||
MAPM func(void) const {return func(myDigits());}
|
||||
|
||||
MAPM_1aryFunc(sqrt)
|
||||
MAPM_1aryFunc(cbrt)
|
||||
MAPM_1aryFunc(log)
|
||||
MAPM_1aryFunc(exp)
|
||||
MAPM_1aryFunc(log10)
|
||||
MAPM_1aryFunc(sin)
|
||||
MAPM_1aryFunc(asin)
|
||||
MAPM_1aryFunc(cos)
|
||||
MAPM_1aryFunc(acos)
|
||||
MAPM_1aryFunc(tan)
|
||||
MAPM_1aryFunc(atan)
|
||||
MAPM_1aryFunc(sinh)
|
||||
MAPM_1aryFunc(asinh)
|
||||
MAPM_1aryFunc(cosh)
|
||||
MAPM_1aryFunc(acosh)
|
||||
MAPM_1aryFunc(tanh)
|
||||
MAPM_1aryFunc(atanh)
|
||||
#undef MAPM_1aryFunc
|
||||
|
||||
void sincos(MAPM &sinR, MAPM &cosR, int toDigits)
|
||||
{
|
||||
m_apm_sin_cos(sinR.val(), cosR.val(), toDigits, cval());
|
||||
}
|
||||
void sincos(MAPM &sinR, MAPM &cosR)
|
||||
{
|
||||
sincos(sinR, cosR, myDigits());
|
||||
}
|
||||
MAPM pow(const MAPM &m, int toDigits) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_pow(ret.val(), toDigits, cval(),
|
||||
m.cval());
|
||||
return ret;
|
||||
}
|
||||
MAPM pow(const MAPM &m) const
|
||||
{
|
||||
return pow(m, digits(m));
|
||||
}
|
||||
MAPM atan2(const MAPM &x, int toDigits) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_arctan2(ret.val(), toDigits, cval(),
|
||||
x.cval());
|
||||
return ret;
|
||||
}
|
||||
MAPM atan2(const MAPM &x) const
|
||||
{
|
||||
return atan2(x, digits(x));
|
||||
}
|
||||
|
||||
MAPM gcd(const MAPM &m) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_gcd(ret.val(), cval(), m.cval());
|
||||
return ret;
|
||||
}
|
||||
|
||||
MAPM lcm(const MAPM &m) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_lcm(ret.val(), cval(), m.cval());
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MAPM random(void)
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_get_random(ret.val());
|
||||
return ret;
|
||||
}
|
||||
|
||||
MAPM floor(void) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_floor(ret.val(), cval());
|
||||
return ret;
|
||||
}
|
||||
MAPM ceil(void) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_ceil(ret.val(), cval());
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Functions defined only on integers: */
|
||||
MAPM factorial(void) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_factorial(ret.val(), cval());
|
||||
return ret;
|
||||
}
|
||||
MAPM ipow_nr(int p) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_integer_pow_nr(ret.val(),
|
||||
cval(), p);
|
||||
return ret;
|
||||
}
|
||||
MAPM ipow(int p, int toDigits) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_integer_pow(ret.val(),
|
||||
toDigits, cval(), p);
|
||||
return ret;
|
||||
}
|
||||
MAPM ipow(int p) const
|
||||
{
|
||||
return ipow(p, myDigits());
|
||||
}
|
||||
MAPM integer_divide(const MAPM &denom) const
|
||||
{
|
||||
MAPM ret;
|
||||
m_apm_integer_divide(ret.val(), cval(),
|
||||
denom.cval());
|
||||
return ret;
|
||||
}
|
||||
void integer_div_rem(const MAPM &denom, MAPM ", MAPM &rem) const
|
||||
{
|
||||
m_apm_integer_div_rem(quot.val(), rem.val(), cval(),
|
||||
denom.cval());
|
||||
}
|
||||
MAPM div(const MAPM &denom) const
|
||||
{
|
||||
return integer_divide(denom);
|
||||
}
|
||||
MAPM rem(const MAPM &denom) const
|
||||
{
|
||||
MAPM ret, ignored;
|
||||
integer_div_rem(denom, ignored, ret);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
/* math.h-style functions: */
|
||||
|
||||
inline MAPM fabs(const MAPM &m)
|
||||
{
|
||||
return m.abs();
|
||||
}
|
||||
inline MAPM factorial(const MAPM &m)
|
||||
{
|
||||
return m.factorial();
|
||||
}
|
||||
inline MAPM floor(const MAPM &m)
|
||||
{
|
||||
return m.floor();
|
||||
}
|
||||
inline MAPM ceil(const MAPM &m)
|
||||
{
|
||||
return m.ceil();
|
||||
}
|
||||
inline MAPM get_random(void)
|
||||
{
|
||||
return MAPM::random();
|
||||
}
|
||||
|
||||
/* I got tired of typing the various declarations for a simple
|
||||
1-ary real-to-real function on MAPM's; hence this define:
|
||||
*/
|
||||
#define MAPM_1aryFunc(func) \
|
||||
inline MAPM func(const MAPM &m) {return m.func();} \
|
||||
inline MAPM func(const MAPM &m,int toDigits) {return m.func(toDigits);}
|
||||
|
||||
/* Define a big block of simple functions: */
|
||||
MAPM_1aryFunc(sqrt)
|
||||
MAPM_1aryFunc(cbrt)
|
||||
MAPM_1aryFunc(log)
|
||||
MAPM_1aryFunc(exp)
|
||||
MAPM_1aryFunc(log10)
|
||||
MAPM_1aryFunc(sin)
|
||||
MAPM_1aryFunc(asin)
|
||||
MAPM_1aryFunc(cos)
|
||||
MAPM_1aryFunc(acos)
|
||||
MAPM_1aryFunc(tan)
|
||||
MAPM_1aryFunc(atan)
|
||||
MAPM_1aryFunc(sinh)
|
||||
MAPM_1aryFunc(asinh)
|
||||
MAPM_1aryFunc(cosh)
|
||||
MAPM_1aryFunc(acosh)
|
||||
MAPM_1aryFunc(tanh)
|
||||
MAPM_1aryFunc(atanh)
|
||||
#undef MAPM_1aryFunc
|
||||
|
||||
/* Computes x to the power y */
|
||||
inline MAPM pow(const MAPM &x, const MAPM &y, int toDigits)
|
||||
{
|
||||
return x.pow(y, toDigits);
|
||||
}
|
||||
inline MAPM pow(const MAPM &x, const MAPM &y)
|
||||
{
|
||||
return x.pow(y);
|
||||
}
|
||||
inline MAPM atan2(const MAPM &y, const MAPM &x, int toDigits)
|
||||
{
|
||||
return y.atan2(x, toDigits);
|
||||
}
|
||||
inline MAPM atan2(const MAPM &y, const MAPM &x)
|
||||
{
|
||||
return y.atan2(x);
|
||||
}
|
||||
inline MAPM gcd(const MAPM &u, const MAPM &v)
|
||||
{
|
||||
return u.gcd(v);
|
||||
}
|
||||
inline MAPM lcm(const MAPM &u, const MAPM &v)
|
||||
{
|
||||
return u.lcm(v);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
271
include/pgscript/utilities/mapm-lib/m_apm_lc.h
Normal file
271
include/pgscript/utilities/mapm-lib/m_apm_lc.h
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* M_APM - m_apm_lc.h
|
||||
*
|
||||
* Copyright (C) 1999 - 2007 Michael C. Ring
|
||||
*
|
||||
* Permission to use, copy, and distribute this software and its
|
||||
* documentation for any purpose with or without fee is hereby granted,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation.
|
||||
*
|
||||
* Permission to modify the software is granted. Permission to distribute
|
||||
* the modified code is granted. Modifications are to be distributed by
|
||||
* using the file 'license.txt' as a template to modify the file header.
|
||||
* 'license.txt' is available in the official MAPM distribution.
|
||||
*
|
||||
* This software is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is the local header file needed to build the library
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef M__APM_LOCAL_INC
|
||||
#define M__APM_LOCAL_INC
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "m_apm.h"
|
||||
|
||||
/*
|
||||
* this supports older (and maybe newer?) Borland compilers.
|
||||
* these Borland compilers define __MSDOS__
|
||||
*/
|
||||
|
||||
#ifndef MSDOS
|
||||
#ifdef __MSDOS__
|
||||
#define MSDOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* this supports some newer Borland compilers (i.e., v5.5).
|
||||
*/
|
||||
|
||||
#ifndef MSDOS
|
||||
#ifdef __BORLANDC__
|
||||
#define MSDOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* this supports the LCC-WIN32 compiler
|
||||
*/
|
||||
|
||||
#ifndef MSDOS
|
||||
#ifdef __LCC__
|
||||
#define MSDOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* this supports Micro$oft Visual C++ and also possibly older
|
||||
* straight C compilers as well.
|
||||
*/
|
||||
|
||||
#ifndef MSDOS
|
||||
#ifdef _MSC_VER
|
||||
#define MSDOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* this supports the Metrowerks CodeWarrior 7.0 compiler (I think...)
|
||||
*/
|
||||
|
||||
#ifndef MSDOS
|
||||
#ifdef __MWERKS__
|
||||
#define MSDOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* this supports the MINGW 32 compiler
|
||||
*/
|
||||
|
||||
#ifndef MSDOS
|
||||
#ifdef __MINGW_H
|
||||
#define MSDOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* this supports the Open Watcom 1.0 compiler
|
||||
*/
|
||||
|
||||
#ifndef MSDOS
|
||||
#ifdef __WATCOMC__
|
||||
#define MSDOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* this supports the Digital Mars compiler
|
||||
*/
|
||||
|
||||
#ifndef MSDOS
|
||||
#ifdef __DMC__
|
||||
#define MSDOS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* this supports National Instruments LabWindows CVI
|
||||
*/
|
||||
|
||||
#ifndef _HAVE_NI_LABWIN_CVI_
|
||||
#ifdef _CVI_
|
||||
#define _HAVE_NI_LABWIN_CVI_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If for some reason (RAM limitations, slow floating point, whatever)
|
||||
* you do NOT want to use the FFT multiply algorithm, un-comment the
|
||||
* #define below, delete mapm_fft.c and remove mapm_fft from the build.
|
||||
*/
|
||||
|
||||
/* #define NO_FFT_MULTIPLY */
|
||||
|
||||
/*
|
||||
* use your own memory management functions if desired.
|
||||
* re-define MAPM_* below to point to your functions.
|
||||
* an example is shown below.
|
||||
*/
|
||||
|
||||
/*
|
||||
extern void *memory_allocate(unsigned int);
|
||||
extern void *memory_reallocate(void *, unsigned int);
|
||||
extern void memory_free(void *);
|
||||
|
||||
#define MAPM_MALLOC memory_allocate
|
||||
#define MAPM_REALLOC memory_reallocate
|
||||
#define MAPM_FREE memory_free
|
||||
*/
|
||||
|
||||
/* default: use the standard C library memory functions ... */
|
||||
|
||||
#define MAPM_MALLOC malloc
|
||||
#define MAPM_REALLOC realloc
|
||||
#define MAPM_FREE free
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define M_APM_IDENT 0x6BCC9AE5
|
||||
#define M_APM_RETURN 0
|
||||
#define M_APM_FATAL 1
|
||||
|
||||
/* number of digits in the global constants, PI, E, etc */
|
||||
|
||||
#define VALID_DECIMAL_PLACES 128
|
||||
|
||||
extern int MM_lc_PI_digits;
|
||||
extern int MM_lc_log_digits;
|
||||
|
||||
/*
|
||||
* constants not in m_apm.h
|
||||
*/
|
||||
|
||||
extern M_APM MM_0_5;
|
||||
extern M_APM MM_0_85;
|
||||
extern M_APM MM_5x_125R;
|
||||
extern M_APM MM_5x_64R;
|
||||
extern M_APM MM_5x_256R;
|
||||
extern M_APM MM_5x_Eight;
|
||||
extern M_APM MM_5x_Sixteen;
|
||||
extern M_APM MM_5x_Twenty;
|
||||
extern M_APM MM_lc_PI;
|
||||
extern M_APM MM_lc_HALF_PI;
|
||||
extern M_APM MM_lc_2_PI;
|
||||
extern M_APM MM_lc_log2;
|
||||
extern M_APM MM_lc_log10;
|
||||
extern M_APM MM_lc_log10R;
|
||||
|
||||
/*
|
||||
* prototypes for internal functions
|
||||
*/
|
||||
|
||||
#ifndef NO_FFT_MULTIPLY
|
||||
extern void M_free_all_fft(void);
|
||||
#endif
|
||||
|
||||
extern void M_init_trig_globals(void);
|
||||
extern void M_free_all_add(void);
|
||||
extern void M_free_all_div(void);
|
||||
extern void M_free_all_exp(void);
|
||||
extern void M_free_all_pow(void);
|
||||
extern void M_free_all_rnd(void);
|
||||
extern void M_free_all_set(void);
|
||||
extern void M_free_all_cnst(void);
|
||||
extern void M_free_all_fmul(void);
|
||||
extern void M_free_all_stck(void);
|
||||
extern void M_free_all_util(void);
|
||||
|
||||
extern int M_exp_compute_nn(int *, M_APM, M_APM);
|
||||
extern void M_raw_exp(M_APM, int, M_APM);
|
||||
extern void M_raw_sin(M_APM, int, M_APM);
|
||||
extern void M_raw_cos(M_APM, int, M_APM);
|
||||
extern void M_5x_sin(M_APM, int, M_APM);
|
||||
extern void M_4x_cos(M_APM, int, M_APM);
|
||||
extern void M_5x_do_it(M_APM, int, M_APM);
|
||||
extern void M_4x_do_it(M_APM, int, M_APM);
|
||||
|
||||
extern M_APM M_get_stack_var(void);
|
||||
extern void M_restore_stack(int);
|
||||
extern int M_get_sizeof_int(void);
|
||||
|
||||
extern void M_apm_sdivide(M_APM, int, M_APM, M_APM);
|
||||
extern void M_cos_to_sin(M_APM, int, M_APM);
|
||||
extern void M_limit_angle_to_pi(M_APM, int, M_APM);
|
||||
extern void M_log_near_1(M_APM, int, M_APM);
|
||||
extern void M_get_sqrt_guess(M_APM, M_APM);
|
||||
extern void M_get_cbrt_guess(M_APM, M_APM);
|
||||
extern void M_get_log_guess(M_APM, M_APM);
|
||||
extern void M_get_asin_guess(M_APM, M_APM);
|
||||
extern void M_get_acos_guess(M_APM, M_APM);
|
||||
extern void M_arcsin_near_0(M_APM, int, M_APM);
|
||||
extern void M_arccos_near_0(M_APM, int, M_APM);
|
||||
extern void M_arctan_near_0(M_APM, int, M_APM);
|
||||
extern void M_arctan_large_input(M_APM, int, M_APM);
|
||||
extern void M_log_basic_iteration(M_APM, int, M_APM);
|
||||
extern void M_log_solve_cubic(M_APM, int, M_APM);
|
||||
extern void M_check_log_places(int);
|
||||
extern void M_log_AGM_R_func(M_APM, int, M_APM, M_APM);
|
||||
extern void M_init_util_data(void);
|
||||
extern void M_get_div_rem_addr(UCHAR **, UCHAR **);
|
||||
extern void M_get_div_rem(int, UCHAR *, UCHAR *);
|
||||
extern void M_get_div_rem_10(int, UCHAR *, UCHAR *);
|
||||
extern void M_apm_normalize(M_APM);
|
||||
extern void M_apm_scale(M_APM, int);
|
||||
extern void M_apm_pad(M_APM, int);
|
||||
extern void M_long_2_ascii(char *, long);
|
||||
extern void M_check_PI_places(int);
|
||||
extern void M_calculate_PI_AGM(M_APM, int);
|
||||
extern void M_set_to_zero(M_APM);
|
||||
extern int M_strposition(char *, char *);
|
||||
extern char *M_lowercase(char *);
|
||||
extern void M_apm_log_error_msg(int, const char *);
|
||||
extern void M_apm_round_fixpt(M_APM, int, M_APM);
|
||||
|
||||
#endif
|
||||
18
include/pgscript/utilities/mapm-lib/module.mk
Normal file
18
include/pgscript/utilities/mapm-lib/module.mk
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#######################################################################
|
||||
#
|
||||
# pgAdmin III - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
# module.mk - pgadmin/include/pgscript/utilities/mapm-lib/ Makefile fragment
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
pgadmin3_SOURCES += \
|
||||
include/pgscript/utilities/mapm-lib/m_apm.h \
|
||||
include/pgscript/utilities/mapm-lib/m_apm_lc.h
|
||||
|
||||
EXTRA_DIST += \
|
||||
include/pgscript/utilities/mapm-lib/module.mk \
|
||||
include/pgscript/utilities/mapm-lib/license.txt
|
||||
26
include/pgscript/utilities/module.mk
Normal file
26
include/pgscript/utilities/module.mk
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#######################################################################
|
||||
#
|
||||
# pgAdmin III - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
# module.mk - pgadmin/include/pgscript/utilities/ Makefile fragment
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
pgadmin3_SOURCES += \
|
||||
include/pgscript/utilities/pgsAlloc.h \
|
||||
include/pgscript/utilities/pgsContext.h \
|
||||
include/pgscript/utilities/pgsCopiedPtr.h \
|
||||
include/pgscript/utilities/pgsDriver.h \
|
||||
include/pgscript/utilities/pgsMapm.h \
|
||||
include/pgscript/utilities/pgsScanner.h \
|
||||
include/pgscript/utilities/pgsSharedPtr.h \
|
||||
include/pgscript/utilities/pgsThread.h \
|
||||
include/pgscript/utilities/pgsUtilities.h
|
||||
|
||||
EXTRA_DIST += \
|
||||
include/pgscript/utilities/module.mk
|
||||
|
||||
include include/pgscript/utilities/mapm-lib/module.mk
|
||||
77
include/pgscript/utilities/pgsAlloc.h
Normal file
77
include/pgscript/utilities/pgsAlloc.h
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSALLOC_H
|
||||
#define PGSALLOC_H
|
||||
|
||||
#if defined(PGSDEBUG)
|
||||
|
||||
#include <cstdlib> // malloc and free
|
||||
#include <new> // std::bad_alloc
|
||||
#include <wx/hashmap.h>
|
||||
|
||||
struct pgsMallocInfo
|
||||
{
|
||||
const void *ptr;
|
||||
size_t size;
|
||||
wxString filename;
|
||||
size_t line_nb;
|
||||
};
|
||||
|
||||
WX_DECLARE_VOIDPTR_HASH_MAP(pgsMallocInfo, pgsMallocInfoMap);
|
||||
|
||||
class pgsAlloc
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
pgsAlloc();
|
||||
|
||||
pgsMallocInfoMap m_malloc_info;
|
||||
|
||||
private:
|
||||
|
||||
void add_malloc(const pgsMallocInfo &malloc_info);
|
||||
|
||||
void rm_malloc(const void *ptr);
|
||||
|
||||
public:
|
||||
|
||||
void *pmalloc(size_t size, const char *filename, size_t line_nb);
|
||||
|
||||
void dump();
|
||||
|
||||
void pfree(void *ptr);
|
||||
|
||||
static pgsAlloc &instance();
|
||||
|
||||
};
|
||||
|
||||
void *operator new(size_t size) throw (std::bad_alloc);
|
||||
void *operator new[](size_t size) throw (std::bad_alloc);
|
||||
void *operator new(size_t size, const char *filename, size_t line_nb)
|
||||
throw (std::bad_alloc);
|
||||
void *operator new[](size_t size, const char *filename, size_t line_nb)
|
||||
throw (std::bad_alloc);
|
||||
void operator delete(void *ptr) throw ();
|
||||
void operator delete[](void *ptr) throw ();
|
||||
|
||||
#define pnew new(__FILE__, __LINE__)
|
||||
|
||||
#else
|
||||
|
||||
#define pnew new
|
||||
|
||||
#endif // PGSDEBUG
|
||||
|
||||
#define pdelete(x) if ((x) != 0) { delete x; x = 0; }
|
||||
#define pdeletea(x) if ((x) != 0) { delete[] x; x = 0; }
|
||||
|
||||
#endif /*PGSALLOC_H_*/
|
||||
119
include/pgscript/utilities/pgsContext.h
Normal file
119
include/pgscript/utilities/pgsContext.h
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, 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_*/
|
||||
80
include/pgscript/utilities/pgsCopiedPtr.h
Normal file
80
include/pgscript/utilities/pgsCopiedPtr.h
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSCOPIEDPTR_H_
|
||||
#define PGSCOPIEDPTR_H_
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
template <typename T> class pgsCopiedPtr
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
T *p;
|
||||
|
||||
public:
|
||||
|
||||
pgsCopiedPtr(T *p) :
|
||||
p(p)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pgsCopiedPtr() :
|
||||
p(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pgsCopiedPtr(const pgsCopiedPtr &that) :
|
||||
p(that.p == 0 ? 0 : that.p->clone())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~pgsCopiedPtr()
|
||||
{
|
||||
pdelete(p);
|
||||
}
|
||||
|
||||
pgsCopiedPtr &operator =(pgsCopiedPtr that)
|
||||
{
|
||||
std::swap(p, that.p);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
T &operator *()
|
||||
{
|
||||
return *p;
|
||||
}
|
||||
|
||||
const T &operator *() const
|
||||
{
|
||||
return *p;
|
||||
}
|
||||
|
||||
T *operator ->()
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
const T *operator ->() const
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
const T *get() const
|
||||
{
|
||||
return p;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*PGSCOPIEDPTR_H_*/
|
||||
98
include/pgscript/utilities/pgsDriver.h
Normal file
98
include/pgscript/utilities/pgsDriver.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSDRIVER_H_
|
||||
#define PGSDRIVER_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "pgscript/utilities/pgsScanner.h"
|
||||
#include "pgscript/parser.tab.hh"
|
||||
|
||||
// Forward declaration
|
||||
class pgsContext;
|
||||
|
||||
// Forward declaration
|
||||
class pgsProgram;
|
||||
|
||||
// Forward declaration
|
||||
class pgsThread;
|
||||
|
||||
/** The pgscript namespace is used to encapsulate the three parser classes
|
||||
* pgscript::pgsParser, pgscript::pgsScanner and pgscript::pgsDriver */
|
||||
namespace pgscript
|
||||
{
|
||||
|
||||
/** The pgsDriver class brings together all components. It creates an instance of
|
||||
* the pgsParser and pgsScanner classes and connects them. Then the input stream is
|
||||
* fed into the scanner object and the parser gets its token
|
||||
* sequence. Furthermore the driver object is available in the grammar rules as
|
||||
* a parameter. Therefore the driver class contains a reference to the
|
||||
* structure into which the parsed data is saved. */
|
||||
class pgsDriver
|
||||
{
|
||||
public:
|
||||
/// Construct a new parser driver context
|
||||
pgsDriver(class pgsContext &_context, class pgsProgram &_program,
|
||||
class pgsThread &_thread);
|
||||
|
||||
/// Destroy parser
|
||||
~pgsDriver();
|
||||
|
||||
/// Enable debug output in the flex scanner
|
||||
bool trace_scanning;
|
||||
|
||||
/// Enable debug output in the bison parser
|
||||
bool trace_parsing;
|
||||
|
||||
/** Invoke the scanner and parser for a stream.
|
||||
* @param in input stream
|
||||
* @return true if successfully parsed
|
||||
*/
|
||||
bool parse_stream(std::istream &in);
|
||||
|
||||
/** Invoke the scanner and parser on an input string.
|
||||
* @param input input string
|
||||
* @return true if successfully parsed
|
||||
*/
|
||||
bool parse_string(const wxString &input);
|
||||
|
||||
/** Invoke the scanner and parser on a file. Use parse_stream with a
|
||||
* std::ifstream if detection of file reading errors is required.
|
||||
* @param filename input file name
|
||||
* @param conv multi-byte string converter
|
||||
* @return true if successfully parsed
|
||||
*/
|
||||
bool parse_file(const wxString &filename, wxMBConv &conv = wxConvLocal);
|
||||
|
||||
// To demonstrate pure handling of parse errors, instead of
|
||||
// simply dumping them on the standard error output, we will pass
|
||||
// them to the driver using the following two member functions.
|
||||
|
||||
/** Error handling with associated line number. This can be modified to
|
||||
* output the error e.g. to a dialog box. */
|
||||
void error(const class location &l, const wxString &m);
|
||||
|
||||
/** Pointer to the current lexer instance, this is used to connect the
|
||||
* parser to the scanner. It is used in the yylex macro. */
|
||||
class pgsScanner *lexer;
|
||||
|
||||
/** Reference to the context filled during parsing of the expressions. */
|
||||
class pgsContext &context;
|
||||
|
||||
/** Contains the list of statements to execute. */
|
||||
class pgsProgram &program;
|
||||
|
||||
/** The thread in which this driver is included. */
|
||||
class pgsThread &thread;
|
||||
};
|
||||
|
||||
} // namespace pgscript
|
||||
|
||||
#endif // PGSDRIVER_H_
|
||||
36
include/pgscript/utilities/pgsMapm.h
Normal file
36
include/pgscript/utilities/pgsMapm.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSMAPMLIB_H_
|
||||
#define PGSMAPMLIB_H_
|
||||
|
||||
#include "pgscript/pgScript.h"
|
||||
#include "mapm-lib/m_apm.h"
|
||||
|
||||
WX_DECLARE_OBJARRAY(MAPM, pgsVectorMapm);
|
||||
|
||||
class pgsMapm
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static wxString pgs_mapm_str(const MAPM &m, const bool &as_int = false);
|
||||
|
||||
static MAPM pgs_mapm_round(const MAPM &m);
|
||||
|
||||
static wxString pgs_mapm_str_fixed(const MAPM &m);
|
||||
|
||||
static wxString pgs_mapm_str_float(const MAPM &m);
|
||||
|
||||
static MAPM pgs_str_mapm(const wxString &s);
|
||||
|
||||
};
|
||||
|
||||
#endif /*PGSMAPMLIB_H_*/
|
||||
87
include/pgscript/utilities/pgsScanner.h
Normal file
87
include/pgscript/utilities/pgsScanner.h
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSSCANNER_H_
|
||||
#define PGSSCANNER_H_
|
||||
|
||||
// Flex expects the signature of yylex to be defined in the macro YY_DECL, and
|
||||
// the C++ parser expects it to be declared. We can factor both as follows.
|
||||
|
||||
#ifndef YY_DECL
|
||||
|
||||
#define YY_DECL \
|
||||
pgscript::pgsParser::token_type \
|
||||
pgscript::pgsScanner::lex( \
|
||||
pgscript::pgsParser::semantic_type* yylval, \
|
||||
pgscript::pgsParser::location_type* yylloc \
|
||||
)
|
||||
#endif
|
||||
|
||||
#ifndef __FLEX_LEXER_H
|
||||
#define yyFlexLexer pgsFlexLexer
|
||||
#include "pgscript/FlexLexer.h"
|
||||
#undef yyFlexLexer
|
||||
#endif
|
||||
|
||||
#include "pgscript/parser.tab.hh"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
namespace pgscript
|
||||
{
|
||||
|
||||
/** pgsScanner is a derived class to add some extra function to the scanner
|
||||
* class. Flex itself creates a class named yyFlexLexer, which is renamed using
|
||||
* macros to pgsFlexLexer. However we change the context of the generated
|
||||
* yylex() function to be contained within the pgsScanner class. This is required
|
||||
* because the yylex() defined in pgsFlexLexer has no parameters. */
|
||||
class pgsScanner : public pgsFlexLexer
|
||||
{
|
||||
public:
|
||||
/** Create a new scanner object. The streams arg_yyin and arg_yyout default
|
||||
* to cin and cout, but that assignment is only made when initializing in
|
||||
* yylex(). */
|
||||
pgsScanner(wxMBConv &conv, std::istream *arg_yyin = 0,
|
||||
std::ostream *arg_yyout = 0);
|
||||
|
||||
/** Required for virtual functions */
|
||||
virtual ~pgsScanner();
|
||||
|
||||
/** This is the main lexing function. It is generated by flex according to
|
||||
* the macro declaration YY_DECL above. The generated bison parser then
|
||||
* calls this virtual function to fetch new tokens. */
|
||||
virtual pgsParser::token_type lex(pgsParser::semantic_type *yylval,
|
||||
pgsParser::location_type *yylloc);
|
||||
|
||||
/** Enable debug output (via arg_yyout) if compiled into the scanner. */
|
||||
void set_debug(bool b);
|
||||
|
||||
private:
|
||||
|
||||
/** Corrects column count because of multi-byte UTF8 characters. */
|
||||
int columns(const char &c);
|
||||
|
||||
/** To count parenthesis. */
|
||||
int m_parent;
|
||||
|
||||
std::string query, dollar, str;
|
||||
|
||||
int comment_caller, string_caller;
|
||||
|
||||
pgscript::pgsParser::token_type query_token;
|
||||
|
||||
wxMBConv &m_conv;
|
||||
|
||||
};
|
||||
|
||||
} // namespace pgscript
|
||||
|
||||
#endif // PGSSCANNER_H_
|
||||
99
include/pgscript/utilities/pgsSharedPtr.h
Normal file
99
include/pgscript/utilities/pgsSharedPtr.h
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgScript - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2002 - 2016, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef PGSSHAREDPTR_H_
|
||||
#define PGSSHAREDPTR_H_
|
||||
|
||||
template <typename T> class pgsSharedPtr
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
struct count
|
||||
{
|
||||
long c;
|
||||
|
||||
T *q;
|
||||
|
||||
count(T *q) :
|
||||
c(1), q(q)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~count()
|
||||
{
|
||||
pdelete(q);
|
||||
}
|
||||
};
|
||||
|
||||
count *p;
|
||||
|
||||
public:
|
||||
|
||||
pgsSharedPtr(T *q) :
|
||||
p(pnew count(q))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pgsSharedPtr() :
|
||||
p(pnew count(0))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
pgsSharedPtr(const pgsSharedPtr &that) :
|
||||
p(that.p)
|
||||
{
|
||||
++p->c;
|
||||
}
|
||||
|
||||
~pgsSharedPtr()
|
||||
{
|
||||
if (!--p->c)
|
||||
{
|
||||
pdelete(p);
|
||||
}
|
||||
}
|
||||
|
||||
pgsSharedPtr &operator =(pgsSharedPtr that)
|
||||
{
|
||||
std::swap(p, that.p);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
T &operator *()
|
||||
{
|
||||
return *(p->q);
|
||||
}
|
||||
|
||||
const T &operator *() const
|
||||
{
|
||||
return *(p->q);
|
||||
}
|
||||
|
||||
T *operator ->()
|
||||
{
|
||||
return p->q;
|
||||
}
|
||||
|
||||
const T *operator ->() const
|
||||
{
|
||||
return p->q;
|
||||
}
|
||||
|
||||
const T *get() const
|
||||
{
|
||||
return p->q;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*PGSSHAREDPTR_H_*/
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue