1 // textprocessing.cpp - Text processing subroutines.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
24 #include "textprocessing.h"
26 void EscapeString(wxString *ReceivedString, bool StripQuotes)
29 ReceivedString->Replace(wxT("\\"), wxT("\\\\"), TRUE);
30 ReceivedString->Replace(wxT(","), wxT("\\,"), TRUE);
31 ReceivedString->Replace(wxT(";"), wxT("\\;"), TRUE);
32 ReceivedString->Replace(wxT("\r\n"), wxT("\\n"), TRUE);
33 ReceivedString->Replace(wxT("\n"), wxT("\\n"), TRUE);
35 if (StripQuotes == TRUE){
37 ReceivedString->Replace(wxT("\""), wxT(""), TRUE);
43 void GetEscapeString(wxTextCtrl *TextCtrl, wxString *ProcessString, bool StripQuotes)
46 *ProcessString = TextCtrl->GetValue();
47 EscapeString(ProcessString, StripQuotes);
51 void GetEscapeString(wxComboBox *ComboCtrl, wxString *ProcessString, bool StripQuotes)
54 *ProcessString = ComboCtrl->GetValue();
55 EscapeString(ProcessString, StripQuotes);
59 void GetEscapeString(wxChoice *ChoiceCtrl, wxString *ProcessString, bool StripQuotes)
62 *ProcessString = ChoiceCtrl->GetString(ChoiceCtrl->GetSelection());
63 EscapeString(ProcessString, StripQuotes);
67 void CaptureString(wxString *ProcessString, bool StripQuotes)
70 ProcessString->Replace(wxT("\\n"), wxT("\n"), TRUE);
71 ProcessString->Replace(wxT("\\;"), wxT(";"), TRUE);
72 ProcessString->Replace(wxT("\\,"), wxT(","), TRUE);
73 ProcessString->Replace(wxT("\\\\"), wxT("\\"), TRUE);
75 if (StripQuotes == TRUE){
77 ProcessString->Replace(wxT("\""), wxT(""), TRUE);
83 void ConvertToHTML(wxString *ProcessString)
86 ProcessString->Replace(wxT("&"), wxT("&"), TRUE);
87 ProcessString->Replace(wxT("<"), wxT("<"), TRUE);
88 ProcessString->Replace(wxT(">"), wxT(">"), TRUE);
89 ProcessString->Replace(wxT("\n"), wxT("<br>"), TRUE);
93 void DeleteMapDataProcess(int IndexNum, std::map<int, std::string>* MapData){
94 MapData->erase(IndexNum);
97 void DeleteMapDataProcess(int IndexNum, std::map<int, wxString>* MapData){
98 MapData->erase(IndexNum);
101 void DeleteMapDataProcess(int IndexNum, std::map<int, int>* MapData){
102 MapData->erase(IndexNum);
105 void DeleteMapDataProcess(int IndexNum, std::map<int, bool>* MapData){
106 MapData->erase(IndexNum);
110 template <typename ArgMap, typename... Args>
111 void DeleteMapData(ArgMap* ArgMapPtr, Args*... ArgsList){
113 //DeleteMapDataProcess(ArgMapPtr);
115 DeleteMapData(ArgsList...);