-
Notifications
You must be signed in to change notification settings - Fork 32
/
AddInNative.h
128 lines (114 loc) · 3.86 KB
/
AddInNative.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#ifndef __ADDINNATIVE_H__
#define __ADDINNATIVE_H__
#define PCRE2_STATIC
#define PCRE2_CODE_UNIT_WIDTH 16
//#define PCRE2_LOCAL_WIDTH 16
#include "pcer2/pcre2.h"
#include "ComponentBase.h"
#include "AddInDefBase.h"
#include "IMemoryManager.h"
#include <vector>
#include <map>
#include <array>
#include <locale.h>
#include "StrConv.h"
#include "json.h"
struct ResultStruct {
std::basic_string<char16_t> value;
size_t firstIndex;
};
///////////////////////////////////////////////////////////////////////////////
// class CAddInNative
class CAddInNative : public IComponentBase
{
public:
enum Props
{
ePropCurrentValue = 0,
ePropIgnoreCase,
ePropErrorDescription,
ePropThrowExceptions,
ePropPattern,
ePropGlobal,
ePropFirstIndex,
ePropMultiline,
ePropUCP,
ePropLast // Always last
};
enum Methods
{
eMethMatches = 0,
eMethIsMatch,
eMethNext,
eMethReplace,
eMethCount,
eMethSubMatchesCount,
eMethGetSubMatch,
eMethVersion,
eMethMatchesJSON,
eMethTest,
eMethLast // Always last
};
CAddInNative(void);
virtual ~CAddInNative();
// IInitDoneBase
virtual bool ADDIN_API Init(void*);
virtual bool ADDIN_API setMemManager(void* mem);
virtual long ADDIN_API GetInfo();
virtual void ADDIN_API Done();
// ILanguageExtenderBase
virtual bool ADDIN_API RegisterExtensionAs(WCHAR_T**);
virtual long ADDIN_API GetNProps();
virtual long ADDIN_API FindProp(const WCHAR_T* wsPropName);
virtual const WCHAR_T* ADDIN_API GetPropName(long lPropNum, long lPropAlias);
virtual bool ADDIN_API GetPropVal(const long lPropNum, tVariant* pvarPropVal);
virtual bool ADDIN_API SetPropVal(const long lPropNum, tVariant* varPropVal);
virtual bool ADDIN_API IsPropReadable(const long lPropNum);
virtual bool ADDIN_API IsPropWritable(const long lPropNum);
virtual long ADDIN_API GetNMethods();
virtual long ADDIN_API FindMethod(const WCHAR_T* wsMethodName);
virtual const WCHAR_T* ADDIN_API GetMethodName(const long lMethodNum,
const long lMethodAlias);
virtual long ADDIN_API GetNParams(const long lMethodNum);
virtual bool ADDIN_API GetParamDefValue(const long lMethodNum, const long lParamNum,
tVariant *pvarParamDefValue);
virtual bool ADDIN_API HasRetVal(const long lMethodNum);
virtual bool ADDIN_API CallAsProc(const long lMethodNum,
tVariant* paParams, const long lSizeArray);
virtual bool ADDIN_API CallAsFunc(const long lMethodNum,
tVariant* pvarRetValue, tVariant* paParams, const long lSizeArray);
// LocaleBase
virtual void ADDIN_API SetLocale(const WCHAR_T* loc);
private:
bool search(tVariant* paParams);
bool searchJSON(tVariant* pvarRetValue, tVariant* paParams);
bool replace(tVariant* pvarRetValue, tVariant* paParams);
bool match(tVariant* pvarRetValue, tVariant* paParams);
bool getSubMatch(tVariant* pvarRetValue, tVariant* paParams);
void version(tVariant* pvarRetValue);
void SetLastError(const char16_t* error);
//void GetStrParam(std::wstring& str, tVariant* paParams, const long paramIndex);
pcre2_code* GetPattern(const tVariant *tvPattern);
// Attributes
IAddInDefBase *m_iConnect;
IMemoryManager *m_iMemory;
int m_PropCountOfItemsInSearchResult;
std::vector<ResultStruct> vResults;
std::map<size_t, std::vector<std::basic_string<char16_t>>> mSubMatches;
int iCurrentPosition;
std::basic_string<char16_t> sErrorDescription;
bool bThrowExceptions;
bool bIgnoreCase;
bool bMultiline;
bool bUCP;
pcre2_code* rePattern;
std::basic_string<char16_t> sPattern;
/*#if defined( __linux__ ) || defined(__APPLE__) || defined(__ANDROID__)
std::u16string uPattern;
#endif*/
bool isPattern;
bool bGlobal;
bool bHierarchicalResultIteration;
size_t uiSubMatchesCount;
};
#endif //__ADDINNATIVE_H__