Skip to content

Commit d734024

Browse files
First version
Uploading the core project, with out the Scintilla and Boost Library. I'll uploads those libraries, once I can figure out what's the minimum required files for use with this project.
1 parent c5f7462 commit d734024

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+7272
-0
lines changed

RegexAssistant.sln

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.1585
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RegexAssistant", "RegexAssistant\RegexAssistant.vcxproj", "{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}"
7+
ProjectSection(ProjectDependencies) = postProject
8+
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76} = {C4E80941-26F9-4AE0-867B-58AB5B5A9E76}
9+
EndProjectSection
10+
EndProject
11+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SciLexer", "scintilla\vcbuild\SciLexer.vcxproj", "{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}"
12+
EndProject
13+
Global
14+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
15+
Debug|ARM64 = Debug|ARM64
16+
Debug|x64 = Debug|x64
17+
Debug|x86 = Debug|x86
18+
Release|ARM64 = Release|ARM64
19+
Release|x64 = Release|x64
20+
Release|x86 = Release|x86
21+
EndGlobalSection
22+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
23+
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Debug|ARM64.ActiveCfg = Debug|Win32
24+
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Debug|x64.ActiveCfg = Debug|x64
25+
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Debug|x64.Build.0 = Debug|x64
26+
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Debug|x86.ActiveCfg = Debug|Win32
27+
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Debug|x86.Build.0 = Debug|Win32
28+
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Release|ARM64.ActiveCfg = Release|Win32
29+
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Release|x64.ActiveCfg = Release|x64
30+
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Release|x64.Build.0 = Release|x64
31+
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Release|x86.ActiveCfg = Release|Win32
32+
{56B23F15-38BE-4A4D-BD7D-0D5213D2AEB7}.Release|x86.Build.0 = Release|Win32
33+
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Debug|ARM64.ActiveCfg = Debug|Win32
34+
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Debug|x64.ActiveCfg = Debug|x64
35+
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Debug|x64.Build.0 = Debug|x64
36+
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Debug|x86.ActiveCfg = Debug|Win32
37+
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Debug|x86.Build.0 = Debug|Win32
38+
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Release|ARM64.ActiveCfg = Release|Win32
39+
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Release|x64.ActiveCfg = Release|x64
40+
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Release|x64.Build.0 = Release|x64
41+
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Release|x86.ActiveCfg = Release|Win32
42+
{C4E80941-26F9-4AE0-867B-58AB5B5A9E76}.Release|x86.Build.0 = Release|Win32
43+
EndGlobalSection
44+
GlobalSection(SolutionProperties) = preSolution
45+
HideSolutionNode = FALSE
46+
EndGlobalSection
47+
GlobalSection(ExtensibilityGlobals) = postSolution
48+
SolutionGuid = {D2337E3C-ACD5-476E-8CA0-A5B2C72A909E}
49+
EndGlobalSection
50+
EndGlobal

RegexAssistant/CAboutDlg.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "pch.h"
2+
#include "framework.h"
3+
#include "RegexAssistant.h"
4+
#include "CAboutDlg.h"
5+
6+
CAboutDlg::CAboutDlg() : CDialogEx( IDD_ABOUTBOX )
7+
{
8+
}
9+
10+
void CAboutDlg::DoDataExchange( CDataExchange* pDX )
11+
{
12+
CDialogEx::DoDataExchange( pDX );
13+
}
14+
15+
BEGIN_MESSAGE_MAP( CAboutDlg, CDialogEx )
16+
END_MESSAGE_MAP()
17+

RegexAssistant/CAboutDlg.h

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
#include "RegexAssistantDlg.h"
4+
5+
// CAboutDlg dialog used for App About
6+
class CAboutDlg : public CDialogEx
7+
{
8+
public:
9+
CAboutDlg();
10+
11+
// Dialog Data
12+
#ifdef AFX_DESIGN_TIME
13+
enum { IDD = IDD_ABOUTBOX };
14+
#endif
15+
16+
protected:
17+
virtual void DoDataExchange( CDataExchange* pDX ); // DDX/DDV support
18+
19+
// Implementation
20+
protected:
21+
DECLARE_MESSAGE_MAP()
22+
};

RegexAssistant/ClipboardXX.hpp

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include <exception>
5+
#include <string.h>
6+
7+
#if defined(_WIN32) || defined(WIN32)
8+
#define WINDOWS 1
9+
#else
10+
#define LINUX 1
11+
#endif
12+
13+
14+
class CExceptionXX : public std::exception{
15+
private:
16+
const char* m_pReason;
17+
18+
public:
19+
CExceptionXX(const char* pReason) : m_pReason(pReason){};
20+
21+
const char* what(){
22+
return m_pReason;
23+
}
24+
};
25+
26+
class IClipboardOS{
27+
protected:
28+
// not accessable from other files :)
29+
IClipboardOS(){};
30+
31+
public:
32+
virtual void CopyText(const char* , size_t ){};
33+
virtual void PasteText(std::string &){};
34+
};
35+
class CClipboardXX;
36+
37+
38+
39+
#ifdef WINDOWS
40+
41+
42+
#include <Windows.h>
43+
44+
class CClipboardWindows: public IClipboardOS{
45+
private:
46+
CClipboardWindows(){
47+
if(!OpenClipboard(0)){
48+
throw CExceptionXX("Cannot open clipboard!");
49+
}
50+
}
51+
52+
public:
53+
~CClipboardWindows(){
54+
CloseClipboard();
55+
}
56+
57+
void CopyText(const char* pText, size_t Length){
58+
if(!EmptyClipboard())
59+
throw CExceptionXX("Cannot empty clipboard!");
60+
61+
HGLOBAL pGlobal = GlobalAlloc(GMEM_FIXED, (Length + 1)* sizeof(char));
62+
63+
#ifdef _MSC_VER
64+
strcpy_s((char *)pGlobal, (Length + 1)*sizeof(char), pText);
65+
#else
66+
strncpy((char *)pGlobal, pText, Length);
67+
#endif
68+
69+
SetClipboardData(CF_TEXT, pGlobal);
70+
71+
GlobalFree(pGlobal);
72+
}
73+
74+
void PasteText(std::string &sString){
75+
char* pResult = (char*) GetClipboardData(CF_TEXT);
76+
77+
if(pResult != NULL){
78+
sString = pResult;
79+
GlobalFree(pResult);
80+
}
81+
}
82+
83+
friend class CClipboardXX;
84+
};
85+
86+
#elif LINUX
87+
88+
#include <QGuiApplication>
89+
#include <QClipboard>
90+
91+
// for some reason have to declare Qt App in global (idk why)
92+
static int gs_FakeArgc = 1;
93+
static QGuiApplication gs_GuiApp(gs_FakeArgc, nullptr);
94+
95+
class CClipboardLinux: public IClipboardOS{
96+
private:
97+
QClipboard* m_pClipboard;
98+
99+
CClipboardLinux(){
100+
m_pClipboard = gs_GuiApp.clipboard();
101+
}
102+
103+
public:
104+
~CClipboardLinux(){
105+
gs_GuiApp.quit();
106+
}
107+
108+
void CopyText(const char* pText, size_t Length){
109+
m_pClipboard->setText(pText, QClipboard::Mode::Clipboard);
110+
}
111+
112+
void PasteText(std::string &sString){
113+
sString = m_pClipboard->text().toStdString();
114+
}
115+
116+
friend class CClipboardXX;
117+
};
118+
119+
#endif
120+
121+
class CClipboardXX{
122+
private:
123+
IClipboardOS* m_pClipboard = new
124+
125+
#ifdef WINDOWS
126+
CClipboardWindows();
127+
#elif LINUX
128+
CClipboardLinux();
129+
#endif
130+
131+
132+
public:
133+
~CClipboardXX(){
134+
delete m_pClipboard;
135+
}
136+
void operator<<(const char* pText){
137+
m_pClipboard->CopyText(pText, strlen(pText));
138+
}
139+
140+
void operator<<(std::string &sText){
141+
m_pClipboard->CopyText(sText.c_str(), sText.size());
142+
}
143+
144+
void operator>>(std::string &sResult){
145+
m_pClipboard->PasteText(sResult);
146+
}
147+
};

RegexAssistant/CommonFunction.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "pch.h"
2+
#include "CommonFunctions.h"
3+
#include <string>
4+
#include <codecvt>
5+
#include <locale>
6+
#include <boost/algorithm/string/replace.hpp>
7+
8+
namespace FXString
9+
{
10+
std::wstring ToWString(std::string src) {
11+
return std::wstring_convert<std::codecvt_utf8<wchar_t>>().from_bytes(src);
12+
}
13+
14+
std::string ToString(std::wstring src ) {
15+
return std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(src);
16+
}
17+
18+
void ReplaceAll(std::string &str, const std::string &searchStr, const std::string &ReplacementStr) {
19+
boost::replace_all(str, searchStr, ReplacementStr);
20+
}
21+
22+
std::string CopyAndReplaceAll(std::string str, const std::string &searchStr, const std::string &ReplacementStr)
23+
{
24+
ReplaceAll(str, searchStr, ReplacementStr);
25+
return str;
26+
}
27+
}
28+

RegexAssistant/CommonFunctions.h

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include <cstring>
5+
#include <mutex>
6+
7+
enum { QISUCCESS = 0};
8+
#define LOGEXT "log"
9+
10+
class auto_lock
11+
{
12+
std::mutex mtx;
13+
public:
14+
auto_lock() { mtx.lock(); }
15+
~auto_lock() { mtx.unlock(); }
16+
};
17+
18+
namespace FXString
19+
{
20+
std::wstring ToWString(std::string src);
21+
inline std::wstring ToWString( const std::wstring &src ) { return src; }
22+
inline std::wstring ToWString( const CString &src) { return src.operator LPCWSTR(); }
23+
24+
inline CString ToTString(const char * src) { return ToWString(src).c_str(); }
25+
inline CString ToTString(const wchar_t * src) { return src; }
26+
27+
std::string ToString( std::wstring src);
28+
inline std::string ToString( const std::string &src ) { return src; }
29+
//inline std::string ToString( const CString &src ) { return ToString( std::wstring(src.operator LPCWSTR()) ); }
30+
31+
std::string CopyAndReplaceAll(std::string src, const std::string &searchStr, const std::string &ReplacementStr);
32+
void ReplaceAll(std::string &src, const std::string &searchStr, const std::string &ReplacementStr);
33+
34+
template <class strType1, class strType2> bool MatchesNoCase(strType1 str1, strType2 str2)
35+
{
36+
std::wstring wstr1 = ToWString(str1);
37+
std::wstring wstr2 = ToWString(str2);
38+
return (0 == _wcsicmp(wstr1.c_str(), wstr2.c_str()));
39+
}
40+
41+
inline size_t StrLen(const char * str) { return strlen(str); }
42+
inline size_t StrLen(const wchar_t * str) { return wcslen(str); }
43+
inline size_t StrLen(const CString &str) { return static_cast <size_t>(str.GetLength()); }
44+
45+
inline DWORD StrDwLen( const char * str ) { return static_cast<DWORD>(strlen( str )); }
46+
inline DWORD StrDwLen( const wchar_t * str ) { return static_cast<DWORD>(wcslen( str )); }
47+
inline DWORD StrDwLen( const CString &str ) { return static_cast<DWORD>(str.GetLength()); }
48+
}
49+
50+

0 commit comments

Comments
 (0)