| 1 |
#ifndef PPTABLE_H |
| 2 |
#define PPTABLE_H |
| 3 |
|
| 4 |
#include <wx/arrstr.h> |
| 5 |
#include <map> |
| 6 |
#include <wx/ffile.h> |
| 7 |
#include <vector> |
| 8 |
#include <string> |
| 9 |
#include <list> |
| 10 |
#include <set> |
| 11 |
|
| 12 |
|
| 13 |
#ifndef WXDLLIMPEXP_CL |
| 14 |
|
| 15 |
#ifdef WXMAKINGDLL_CL |
| 16 |
# define WXDLLIMPEXP_CL __declspec(dllexport) |
| 17 |
#elif defined(WXUSINGDLL_CL) |
| 18 |
# define WXDLLIMPEXP_CL __declspec(dllimport) |
| 19 |
#else |
| 20 |
# define WXDLLIMPEXP_CL |
| 21 |
#endif |
| 22 |
|
| 23 |
#endif |
| 24 |
|
| 25 |
|
| 26 |
struct WXDLLIMPEXP_CL CLReplacement { |
| 27 |
bool is_compound; |
| 28 |
bool is_ok; |
| 29 |
std::string full_pattern; |
| 30 |
std::string searchFor; |
| 31 |
std::string replaceWith; |
| 32 |
void construct(const std::string& pattern, const std::string& replacement); |
| 33 |
}; |
| 34 |
|
| 35 |
typedef std::list<CLReplacement> CLReplacementList; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
bool CLReplacePattern(const wxString &in, const wxString& pattern, const wxString& replacement, wxString &output); |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
bool CLReplacePatternA(const std::string& in, const CLReplacement& repl, std::string& outStr); |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
struct WXDLLIMPEXP_CL PPToken { |
| 69 |
enum { |
| 70 |
IsFunctionLike = 0x00000001, |
| 71 |
IsValid = 0x00000002, |
| 72 |
IsOverridable = 0x00000004 |
| 73 |
}; |
| 74 |
|
| 75 |
int line; |
| 76 |
wxString name; |
| 77 |
wxString replacement; |
| 78 |
wxArrayString args; |
| 79 |
size_t flags; |
| 80 |
wxString fileName; |
| 81 |
|
| 82 |
PPToken() : line(0), flags(IsOverridable) |
| 83 |
{} |
| 84 |
|
| 85 |
~PPToken() |
| 86 |
{} |
| 87 |
|
| 88 |
void expandOnce(const wxArrayString& initList); |
| 89 |
void processArgs(const wxString &argsList); |
| 90 |
wxString signature() const; |
| 91 |
void print(wxFFile &fp); |
| 92 |
static bool readInitList(const wxString &in, int from, wxString& initList, wxArrayString &initListArr); |
| 93 |
static bool readInitList(const std::string &in, size_t from, std::string& initList, std::vector<std::string> &initListArr); |
| 94 |
void squeeze(); |
| 95 |
wxString fullname() const; |
| 96 |
|
| 97 |
}; |
| 98 |
|
| 99 |
class WXDLLIMPEXP_CL PPTable |
| 100 |
{ |
| 101 |
std::map<wxString, PPToken> m_table; |
| 102 |
std::set<wxString> m_namesUsed; |
| 103 |
|
| 104 |
public: |
| 105 |
static PPTable* Instance(); |
| 106 |
static void Release(); |
| 107 |
|
| 108 |
private: |
| 109 |
PPTable(); |
| 110 |
~PPTable(); |
| 111 |
|
| 112 |
public: |
| 113 |
PPToken Token(const wxString &name); |
| 114 |
bool Contains(const wxString &name); |
| 115 |
void Add (const PPToken& token); |
| 116 |
void AddUsed(const wxString& name); |
| 117 |
void Print(wxFFile &fp); |
| 118 |
wxString Export(); |
| 119 |
void Clear(); |
| 120 |
void ClearNamesUsed(); |
| 121 |
void Squeeze(); |
| 122 |
|
| 123 |
const std::map<wxString, PPToken>& GetTable() const { |
| 124 |
return m_table; |
| 125 |
} |
| 126 |
|
| 127 |
const std::set<wxString>& GetNamesUsed() const { |
| 128 |
return m_namesUsed; |
| 129 |
} |
| 130 |
}; |
| 131 |
#endif |