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 ResetUnusedString(wxString *ProcessString)
86 ProcessString->Replace(wxT("\\\\"), wxT("\\"), TRUE);
87 ProcessString->Replace(wxT("\n"), wxT(""), TRUE);
88 ProcessString->Replace(wxT("\\;"), wxT(";"), TRUE);
89 ProcessString->Replace(wxT("\\,"), wxT(","), TRUE);
93 void ConvertToHTML(wxString *ProcessString)
96 ProcessString->Replace(wxT("&"), wxT("&"), TRUE);
97 ProcessString->Replace(wxT("<"), wxT("<"), TRUE);
98 ProcessString->Replace(wxT(">"), wxT(">"), TRUE);
99 ProcessString->Replace(wxT("\n"), wxT("<br>"), TRUE);
103 void DeleteMapDataProcess(int IndexNum, std::map<int, std::string>* MapData){
104 MapData->erase(IndexNum);
107 void DeleteMapDataProcess(int IndexNum, std::map<int, wxString>* MapData){
108 MapData->erase(IndexNum);
111 void DeleteMapDataProcess(int IndexNum, std::map<int, int>* MapData){
112 MapData->erase(IndexNum);
115 void DeleteMapDataProcess(int IndexNum, std::map<int, bool>* MapData){
116 MapData->erase(IndexNum);
119 bool MapDataExists(int *ItemIndex, std::map<int,wxString> *MapPtr){
121 if (MapPtr->find(*ItemIndex) == MapPtr->end()){
133 bool MapDataExists(int *ItemIndex, std::map<int,int> *MapPtr){
135 if (MapPtr->find(*ItemIndex) == MapPtr->end()){
148 template <typename ArgMap, typename... Args>
149 void DeleteMapData(ArgMap* ArgMapPtr, Args*... ArgsList){
151 //DeleteMapDataProcess(ArgMapPtr);
153 DeleteMapData(ArgsList...);