1 //////////////////////////////////////////////////////////////////////////
2 //
3 // pgScript - PostgreSQL Tools
4 //
5 // Copyright (C) 2002 - 2016, The pgAdmin Development Team
6 // This software is released under the PostgreSQL Licence
7 //
8 //////////////////////////////////////////////////////////////////////////
9 
10 
11 #ifndef PGSREGEXGEN_H_
12 #define PGSREGEXGEN_H_
13 
14 #include "pgscript/pgScript.h"
15 #include "pgscript/generators/pgsObjectGen.h"
16 #include "pgscript/generators/pgsStringGen.h"
17 
18 WX_DECLARE_OBJARRAY(pgsStringGen, pgsVectorStringGen);
19 
20 class pgsRegexGen : public pgsObjectGen
21 {
22 
23 private:
24 
25 	class pgsRegex
26 	{
27 
28 	private:
29 
30 		pgsVectorChar m_characters;
31 
32 		long m_first;
33 		long m_second;
34 
35 	public:
36 
37 		pgsRegex(const pgsVectorChar &characters, const long &first,
38 		         const long &second);
39 
40 		pgsRegex();
41 
42 		~pgsRegex();
43 
44 		pgsRegex *clone();
45 
46 		/* pgsRegex & operator =(const pgsRegex & that); */
47 
48 		/* pgsRegex(const pgsRegex & that); */
49 
50 		void set_characters(const pgsVectorChar &characters);
51 
52 		void add_character(const wxChar &c);
53 
54 		void set_first(const long &first);
55 
56 		void set_second(const long &second);
57 
58 		const pgsVectorChar &get_characters() const;
59 
60 		const long &get_first() const;
61 
62 		const long &get_second() const;
63 
64 	};
65 
66 private:
67 
68 	wxString m_regex;
69 
70 	bool m_valid;
71 
72 	pgsVectorStringGen m_string_gens;
73 
74 public:
75 
76 	pgsRegexGen(const wxString &regex, const long &seed = wxDateTime::GetTimeNow());
77 
78 	virtual wxString random();
79 
80 	virtual ~pgsRegexGen();
81 
82 	virtual pgsRegexGen *clone();
83 
84 	/* pgsRegexGen & operator =(const pgsRegexGen & that); */
85 
86 	/* pgsRegexGen(const pgsRegexGen & that); */
87 
88 	const bool &is_valid() const;
89 
90 	const pgsVectorStringGen &string_gens() const;
91 
92 	size_t string_gens_size() const;
93 
94 private:
95 
96 	static wxString espace_xml_char(const wxChar &c);
97 
98 	static wxString char_range(const wxChar &b, const wxChar &c);
99 
100 };
101 
102 #endif /*PGSREGEXGEN_H_*/
103